Object.Instantiate in C#

I’m using Instantiate to create GameObjects in C#. If I do something like:

GameObject obj = (GameObject) Instantiate(myPrefab, myPt, Quaternion.Identity);

I get a “cannot cast…” error. In Javascript, I can get a GameObject from a call like this without an error. In C# I can however do something like this:

Transform t = (Transform) Instantiate(myPrefab, myPt, Quaternion.Identity);

So how do I get the GameObject out of this call when using C#? I was thinking of using the Object instanceID, but I’m not sure…

Thanks,

Brian

Nevermind. I just check Unity Answers and saw I could do something like this:

Transform t = (Transform) Instantiate(myPrefab, myPt, Quaternion.Identity);

GameObject obj = t.gameObject;