Delete Component at Runtime

My player needs to have a hingeJoint attached only when he is colliding with a rope. When the player presses “a” for example, we would let go, releasing the rope and falling to the ground. Unfortunately, what I’ve found to happen was that just making the value connectedBody null doesn’t work because the player then hangs where he is in midspace. So the only way I know of to do it is to add/delete the hingeJoint component at runtime. I’ve added the hingeJoint using:

transform.gameObject.AddComponent("hingeJoint");

But I can’t find a way to delete the hingeJoint. Any help would be appreciated.

You want to do

Component.Destroy(yourComponent); 

It can be just this in a mono behaviour:

Destroy(yourComponent);