I Have code like bellow
public interface IFoo
{
int One { get; set; }
string Two { get; set; }
}
public class Foo : IFoo
{
public int One { get; set; }
public string Two { get; set; }
}
public class SomeDto<T>
where T : IFoo
{
public T Fik { get; set; }
public string Faj { get; set; }
}
class Program
{
static void Main(string[] args)
{
var fik = new SomeDto<Foo>() { Fik = new Foo() { One = 1, Two = "ss" }, Faj = "ss" };
var obj = (Object)fik;
// the problematic part
//=======================
var fikl = fik as SomeDto<IFoo>; //do something like that
//or
var fikl = (SomeDto<IFoo>)fik; //do something like that
}
}
How can I work around that problematic part. Make something similar to allow unboxing a generic class but to something more general like interface.
I need this because I have combo box with datasource build upon generics. And I need to find item on the list using to that some properties form generic value.