CodePaste Logo
New Snippet New Snippet Recent Snippets Recent Snippets My Snippets My Snippets Web Code Search Snippets Search
Sign inor Register
Language: C#

Generic

181 Views
Copy Code Show/Hide Line Numbers
 
var realHandler = GetHandler<SomeType>();
var message = GetMessage(); //Returns derived type of SomeType
var handlerType = typeof(IHandler<>);
var genericType = message.GetType();
var genericHandler = handlerType.MakeGenericType(genericType);
 
return realHandler --> as genericHandler would not work
by Hadi Eskandari
  July 19, 2010 @ 8:45am
Tags:

Add a comment


Report Abuse
brought to you by:
West Wind Techologies



If you find this site useful and use it frequently please consider making a donation to support this free service.
Donate