What does <> mean when defining an interface?

I learned about writing my own interfaces and came across an MSDN article " " Interfaces "(C # Programming Guide) ." Everything seems beautiful, except: what does <T> mean or does?

 interface IEquatable<T> { bool Equals(T obj); } 
+4
source share
2 answers

This means that it is a common interface.

You can create an interface like this:

 public interface IMyInterface<T> { T TheThing {get; set;} } 

and you can implement it in various ways:

 public class MyStringClass : IMyInterface<string> { public string TheThing {get; set;} } 

and like this:

 public class MyIntClass : IMyInterface<int> { public int TheThing {get; set;} } 
+21
source

This parametric type means that you can reuse IEquatable for any type ... in "runtime" (but not exactly) instead of T you can use String, Animal, Dog ecc ...

0
source

All Articles