I learning about writing my own interfaces and came across this msdn article. Everything seems fine, except I cannot find anywhere what the < T > means or does. Can anyone help me out?
interface IEquatable<T>
{
bool Equals(T obj);
}
I learning about writing my own interfaces and came across this msdn article. Everything seems fine, except I cannot find anywhere what the < T > means or does. Can anyone help me out?
interface IEquatable<T>
{
bool Equals(T obj);
}
It means that it is a generic interface.
You could create an interface like this:
public interface IMyInterface<T>
{
T TheThing {get; set;}
}
and you could 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;}
}
It is a parametric type means that you could reuse IEquatable for any type... at "runtime" (but not exactly), in place of T, you could use String, Animal, Dog ecc...