M
Michael Groeger
Hi,
is it possible to determine if the PropertyType of a property support IList?
We are inspecting all properties of a Type and we need to care about the
properties which have a type which supports IList. I tried to do the
following:
public void TestPropertiesOfType()
{
System.Type t = typeof (MyClass);
PropertyInfo[] properties = t.GetProperties();
foreach (PropertyInfo pi in properties)
{
if (pi.PropertyType is IList)
Console.WriteLine("Property {0} supports IList", pi.Name);
}
}
public class MyClass
{
public ArrayList MyArrayList
{
get { return _al; }
set { _al = value; }
}
}
ArrayList does support IList, but how can I find this one out? I know that
the above implmentation is incorrect because the Type returned by
pi.PropertyType itself does not support IList.
Any help is appreciated!
Regards,
Michael
is it possible to determine if the PropertyType of a property support IList?
We are inspecting all properties of a Type and we need to care about the
properties which have a type which supports IList. I tried to do the
following:
public void TestPropertiesOfType()
{
System.Type t = typeof (MyClass);
PropertyInfo[] properties = t.GetProperties();
foreach (PropertyInfo pi in properties)
{
if (pi.PropertyType is IList)
Console.WriteLine("Property {0} supports IList", pi.Name);
}
}
public class MyClass
{
public ArrayList MyArrayList
{
get { return _al; }
set { _al = value; }
}
}
ArrayList does support IList, but how can I find this one out? I know that
the above implmentation is incorrect because the Type returned by
pi.PropertyType itself does not support IList.
Any help is appreciated!
Regards,
Michael