- Home /
Question by
Devined · Sep 07, 2014 at 11:07 PM ·
gameobjectmeshfilteraddcomponent
What is happening when you use greater and lass than signs with AddComponent?
I am following a tutorial where it wants me to do the following code:
gameObject.AddComponent<MeshFilter> ().mesh = mesh;
It does not explain however why there are < and > around the MeshFilter, or what they are for. Can anyone enlighten me?
Comment
Answer by AyAMrau · Sep 07, 2014 at 11:11 PM
In this case the signs are used not to mean less than or greater than, but they are a syntax used with generic methods to supply a specific type to be used by the method.
Here's the MSDN page on generic methods
Basically the AddComponent method doesn't define what component should be added, so you are supplying the type you want using this syntax.
Your answer