Tagged with type
What type are you really?
I had an interesting problem the other day. I had a situation where someone could pass a type to my method which could be potentially be a nullable type and I needed to know what the real type actually was. It turned out to be pretty easy to find out. The Type type has a [...]Published in .NET on Friday, May 4th, 2007
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: MSDN typeof documentation MSDN using typeof referencePublished in .NET on Wednesday, October 27th, 2004






