I have a Generic class as below.
Subscriber<T> where T : class
{
public T callback {get; set;}
public USER User {get; set;}
}
T is really an interface for the callback being passed in and around. However as you know when I go to use this Null Reference Exception is thrown. So I go and search stack'O to create an instance of interface T , as you know I can't create an instance of an interface (duh) but I thought maybe there was a way around this. I am using WCF and would like to store the callback object but do it generically as the Subscriber method could be used for other callback contracts. Should I store as object and on the get cast to type T ?
private object _callback;
public object Callback
get
{
return (T)_callback;
}
set
{
_callback = value;
}
Aucun commentaire:
Enregistrer un commentaire