Generics documentation

  • Thread starter Thread starter samuelhon
  • Start date Start date
S

samuelhon

Hi

I've been looking at NetTiers and came across this line:

public static Entity LocateOrCreate<Entity>(string key, string
typeString, Type entityFactoryType) where Entity : class, IEntity,
new()

Just wondered if anyone could point me towards some good documentation
on generics?

Thanks

Sam
 
samuelhon said:
Hi

I've been looking at NetTiers and came across this line:

public static Entity LocateOrCreate<Entity>(string key, string
typeString, Type entityFactoryType) where Entity : class, IEntity,
new()

Just wondered if anyone could point me towards some good documentation
on generics?

Thanks

Sam

For your example, the Entity is a generic type, and it has three
constraints:

1> It has to be a class.
2> It has to implement IEntity
3> The new constraint, which specifies that any type argument in a
generic class declaration must have a public parameterless constructor.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top