Parenting from code doesn't really change the hierarchy

So I tried creating a gameobject from code, and then setting the transform.parent to this.transform, but in the hierarchy of the editor it doesn’t appear as a child, and also when the parent gets destroyed, the child remains…

Any reason to this?

void Start () {
	GameObject newobj = new GameObject("Testing");
	newobj.transform.parent = transform.parent;
	GameObject.Destroy(gameObject, 2);
}	

After 2 seconds, the original object is destroyed, but “Testing” is still there.

Bug in your code. You probably want this:

void Start () {
    GameObject newobj = new GameObject("Testing");
    newobj.transform.parent = transform; // this transform, not the parent
    GameObject.Destroy(gameObject, 2);
}