Passing Type as a parameter
Here’s a useful bit of C# code for creating a method that takes a Type
as a parameter from the microsoft.public.dotnet.languages.csharp group.
Calling code:
MyComponent component;object myobject;MyMethod(myobject, typeof(MyComponent));
Method:
public static void MyMethod(object myobject, Type type) { if(myobject.GetType() == type) { // do something }}
Useful references:







Comments