F
Filip Zawada
Hi,
I've encountered a rather interesting language problem. Suppose I've
got following types:
//class providing usefull static methods
public class GoodBase<T>
{
public static void Met(){};
}
public class SomeEntity
: GoodBase<SomeEntity>
{
}
public interface IDictModel<T>
where T : GoodBase<T>
{
}
public class DictModel<T>
: IDictModel<T>
where T : GoodBase<T>
{
public void Test()
{
GoodBase<SomeEntity>.Met(); //OK
SomeEntity.Met(); //OK
T.Met(); //won't compile
}
}
The question is why can't I call a static method using generic
parameter?
I've specified that T is of type GoodBase<T>, so static methods from
GoodBase should be available by using generic parameter... Isn't
GoodBase<SomeEntity>.Met() actually the same as T.Met()? Why do I have
to repeat myself?
Regards,
Filip Zawada
I've encountered a rather interesting language problem. Suppose I've
got following types:
//class providing usefull static methods
public class GoodBase<T>
{
public static void Met(){};
}
public class SomeEntity
: GoodBase<SomeEntity>
{
}
public interface IDictModel<T>
where T : GoodBase<T>
{
}
public class DictModel<T>
: IDictModel<T>
where T : GoodBase<T>
{
public void Test()
{
GoodBase<SomeEntity>.Met(); //OK
SomeEntity.Met(); //OK
T.Met(); //won't compile
}
}
The question is why can't I call a static method using generic
parameter?
I've specified that T is of type GoodBase<T>, so static methods from
GoodBase should be available by using generic parameter... Isn't
GoodBase<SomeEntity>.Met() actually the same as T.Met()? Why do I have
to repeat myself?
Regards,
Filip Zawada