How would I test a property of a type to see if it is a specified type?
EDIT: My goal is to examine an assembly to see if any of the types in that assembly contain properties that are MyType (or inherited from MyType).
Here is the track I've gone down…
AssemblyName n = new AssemblyName(); n.CodeBase = "file://" + dllName; Assembly a = AppDomain.CurrentDomain.Load(n); foreach (Type t in a.GetTypes()) foreach (PropertyInfo pi in t.GetProperties()) if ( pi.PropertyType is MyType ) // warning CS0184 Console.WriteLine("Found a property that is MyType");
This compiles with warning CS0184: The given expression is never of the provided ('MyType') type