I sometimes see <> in GetComponent<> calls. I see when arrays are being created, usually.
Are these the two main uses of them? Or are they a form of syntax I don’t understand?
I sometimes see <> in GetComponent<> calls. I see when arrays are being created, usually.
Are these the two main uses of them? Or are they a form of syntax I don’t understand?
Hi,
That’s right. In C#, we use []
for arrays and to access elements in arrays, List objects, dictionaries and other collections. And we use <>
for generics like, for example, List<T>
. In the context of Unity, common generics are GetComponent<T>
and FindObjectOfType<T>
.
See also:
This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.