Can someone help me identify what the purpose of this unidentified syntax is. It is an extra little something in the constructor for this object. What I’m trying to figure out is what is the ‘< IdT >’ at the end of the class declaration line? I think that this is something I would find useful, I just need to understand what it is why so many people seem to do this.
using BasicSample.Core.Utils; namespace BasicSample.Core.Domain { /// <summary> /// For a discussion of this object, see /// http://devlicio.us/blogs/billy_mccafferty/archive/2007/04/25/using-equals-gethashcode-effectively.aspx /// </summary> public abstract class DomainObject<IdT> { /// <summary> /// ID may be of type string, int, custom type, etc. /// Setter is protected to allow unit tests to set this property via reflection and to allow /// domain objects more flexibility in setting this for those objects with assigned IDs. /// </summary> public IdT ID { get { return id; } protected set { id = value; } }
Read about Generics: MSDN
That is how you define a generic class. Hence calling
would create a domain object with an Id of type string.
The way you define the ID must be an int.
The way it is defined the id can be any type you want.