C# 4.0 .NET 4.5 Silverlight 5 It seems weird that I cant find the solution so need some help please.
I have base class Base and derived class Child : Base. I have also h
I think this is what you're after:
public class Base where T : EntityObject
{
protected Helper helper;
}
public class Child : Base
{
public Child()
{
helper = new Helper();
}
}
Edit (in response to your edit): You can add a Base
, use like so:
public class Base
{
// put anything here that doesn't rely on the type of T
// if you need things here that would rely on T, use EntityObject and have
// your subclasses provide new implementations using the more specific type
}
public class Base : Base where T : EntityObject
{
protected Helper helper;
}
public class Child : Base
{
public Child()
{
helper = new Helper();
}
}
public class User
{
private Base myBase;
public User(TypeEnum t)
{
if(t == TypeEnum.MyEntity) myBase = new Child();
...