Reputation: 259
Can somebody help me to get a generic object from Interface.My implementation is like the code below:
interface Itest
{
T getObject();
}
public class Test1:Itest
{
public T getObject()
{
return (T)(new logger());
}
}
Upvotes: 0
Views: 63
Reputation: 564373
You typically would need to make the interface generic, then return that specific type from the class, ie:
interface ITest<T>
{
T GetObject();
}
public class Test1 : ITest<Logger>
{
public Logger GetObject()
{
return new Logger();
}
}
Upvotes: 3