How do you add a child through code

Ive looked through the documentation and havnt seen anything obvious.

So just as the title says, how might you create a parent/child through code?

Assign the child’s parent transform, e.g.

void Parent( GameObject parentOb, GameObject childOb )
  childOb.transform.parent = parentOb.transform;

These days as a general rule use SetParent - google

How would you “unAttach” them?