I must honestly say that I do not really understand much about casting, but I thought this would work.
I have a Generic Class Test:
public class Test<T,U>
{
T variable1;
U variable2;
//etc.
}
I need to use this class in a WPF view, and since you can't create generic views in WPF (how lovely) I thought: lets just use a Test<object, object
> for the view, since I am only concerned about working with the string representations of the variables in the view.
So I try:
Test<Foo, Bar> test = new Test<Foo, Bar>();
return test as Test<object, object>;
But that gives me:
Error 1 Cannot convert type 'DomainModel.Tests.Test<T,U>'
to 'DomainModel.Tests.Test<object,object>' via a reference conversion, boxing
conversion, unboxing conversion, wrapping conversion, or null type conversion
I would think that every object must be castable to object?
Anyhow, I am quite stuck now in how to ever use generic classes in WPF...
Any pointer in the right direction?