child object to parent c#

using c#, how do I make a child object leave the parent object and become it’s own parent?

A Transform cannot be it’s own parent, but if you use

transform.parent = null;

on the child object, that will make it a root object.