What does < word > do?

I have been practicing C#, and I am aware that > is more than and < is less than, but I am unsure what they do when they are arranged like this:


I used RawImage as an example of a word that goes in between these two symbols but I am uncertain of what using both symbols this way does. If anybody could help clear things up for me I would be most grateful.

It’s a type parameter, which is used when you need to pass a type of object (rather than a specific instance of an object) as a parameter.

// Here, the <int> parameter is used to specify that myListOfInts is a list of ints 
List<int> myListOfInts = new List<int>();

// Here, <Rigidbody> means that GetComponent should only return the rigidbody component of the
// attached object. 

In the above examples, int and Rigidbody are both types, and <int> and <Rigidbody> is how they are passed as parameters to the List constructor and GetComponent method.

The word between <> represents the type, as tanoshimi explained. To get the big picture: they are used in generic methods, i.e. methods that were created with no particular type in mind, but with a generic type (usually denoted by T).
The behavior of these kind of methods depends on the user specified type: if you for example specify like method<int> the method, although it’s named exactly the same, behaves differently as method<float>; the method code is the same, working “blindly” with whatever type is passed. It’s transparent to the user (ok, programmer).
It’s like overloading.
The differences lie in the use cases:

  • overloading is used when the per type behaviors are very different from each other while generics is used when the behavior is the same for any type the user would input.
  • overloading is used for a well determined number of types while generics is used when the designer has no idea of the future various types the methods/class would accept.

You can also create your own generic classes and methods. For more info take a look here: