I suspect the answer is no, but is it possible to do something like this in C#.NET (v2.0).
class Converter<E>
{
public E Make(object o)
{
return o as E;
}
}
If not, is it possible to check types like this:
public bool IsType(object o, Type t)
{
return o is E;
}
I’m not certain about the terminology so it is rather hard to Google for me.
But my guess is that these two problems are related. Any ideas?
You can cast
otoEusing the () Operator:If you use as,
o as ErequiresEto a be a reference type, because ifois not castable toE, the result is(E)null. You can constrainEto reference types by using the class Constraint: