**Preface I’m very new to generics. I have a class I created called Geno. My Peno class simply contains a string Name property. I’m wondering why I cannot call T.Name from within a method on this class. How would I access the properties on T? Any good resources on how this works?
public class Geno<T> where T : Peno
{
}
public string GetName()
{
return T.Name;
}
Is your
Nameproperty an instance property or a static property? If it’s a static property, you don’t get polymorphism anyway – you could just callPeno.Name.If it’s an instance property, you need an instance on which to call it. For example:
If this doesn’t help, please give a more complete example of what you’re trying to do.