How to return a Type

Here is my code i want to return the Turret Type but it errors with:

Assets/Scripts/GUIManager.cs(104,24): error CS0411: The type arguments for method `GUIManager.GetTurretType(Turret)’ cannot be inferred from the usage. Try specifying the type arguments explicitly

void ShowTurretUpdate()
	{
		Turret turret = platformHit.TurretAtLocation (turretPosition);
		print( GetTurretType (turret));
	}

	T GetTurretType<T>(Turret turret)
	{
		return ((T)turret.GetType());
	}

If you return T you would return an instance of type T.

If you want to return a Type… Well… return a Type… No need to use generics here… Unless you want to do something else.

This looks to me like you want to make a wrapper method for object.GetType(). I don’t know why you would want to do that but this would be the working code…

Type GetTurretType(Turret turret)
{
    return turret.GetType();
}

If you actually want to do something else then to get the type, edit your question :stuck_out_tongue:

ps. add using System; to the top for this line of code to compile.