ow to indicate that T is inherited from other class that implements certain methods:
public Class A
{
public string GetAccessPoint();
public string GetPriorityMap();
}
public Class IndexBuilder<T> where T : A
{
List<string> Go<T>(T obj)
{
string aPt=obj.GetAccessPoint();
string pMap=obj.GetPriorityMap();
}
}
In other words, I cannot access GetAccessPoint and GetPriority map of the obj although I indicated that it is inherited from A.
That's because you redefined what T is when you made the Go method generic. Since T is defined at the class level, there is no need to redefine it in Go. Try this:
public Class IndexBuilder<T> where T : A
{
List<string> Go(T obj)
{
string aPt=obj.GetAccessPoint();
string pMap=obj.GetPriorityMap();
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With