Attaching rigidbody to a HingeJoint via C#

Hello,

Is there a way to attach a rigidbody to a HingeJoint in C#? I tried setting the rigidbody to HingeJoint.rigidbody (i.e. _hingeJoint.rigidbody = _objectTobeAttached.rigidbody), but it says that HingeJoint.rigidbody is read only.

Thanks!

using UnityEngine;
using System.Collections;

[RequireComponent(typeof(HingeJoint))]
public class Example : MonoBehaviour 
{
    HingeJoint joint;

    //Assign in inspector while keeping variable private.
    [SerializeField] Rigidbody cBody;

    void Awake()
    {
        if (!joint)
            joint = GetComponent<HingeJoint>();
        else
        {
            if (!cBody)
                joint.connectedBody = cBody;
        }
    }
}