Please check the following section of code (Simplified version)
my concern is in the ReadPath class where I need to call the GetPath() of the type i am using. How can I achieve this?
public interface IPath
{
string GetPath();
}
public class classA: IPath
{
string GetPath()
{
return "C:\";
}
}
public class classB: IPath
{
string GetPath()
{
return "D:\";
}
}
public class ReadPath<T> where T : IPath
{
public List<T> ReadType()
{
// How to call GetPath() associated with the context type.
}
}
Interfaces are instance based. So if you want to do that, pass in an instance and work with that.
However, there is a concept that is type-based: attributes: