Can I Create A Generic Method of a Type of Interface?
Posted
by DaveDev
on Stack Overflow
See other posts from Stack Overflow
or by DaveDev
Published on 2010-03-26T22:21:49Z
Indexed on
2010/03/26
22:23 UTC
Read the original article
Hit count: 288
Is it possible to create a generic method with a signature like
public static string MyMethod<IMyTypeOfInterface>(object dataToPassToInterface)
{
// an instance of IMyTypeOfInterface knows how to handle
// the data that is passed in
}
Would I have to instantiate the Interface with (T)Activator.CreateInstance();
?
© Stack Overflow or respective owner