L
lucius
..NET 2.0.
In the below code, when GrandChildThing is instanced, the
GrandChildProperty is never set in line 9 of ChildThing. Visual Studio
2005 IntelliSense says that the instance is GrandChildThing, but there
are no properties in the propInfos count and the property is never
set. Why?
public class BaseThing
{
public string ThingOutput;
}
public class ChldThing : BaseThing
{
internal void DoSomething()
{
string yes="yes";
PropertyInfo[] propInfos = this.GetType().GetProperties(); // count is
zero
foreach (PropertyInfo propertyInfo in this.GetType().GetProperties())
{
if ( propertyInfo.Name == "GrandChildProperty")
{
XmlDocument grandchildXml = new XmlDocument();
propertyInfo.SetValue( this , grandchildXml , null );
}
}
}
}
public class GrandChildThing : ChildThing
{
public XmlDocument GrandChildProperty;
public Work()
{
base.DoSomething();
}
}
In the below code, when GrandChildThing is instanced, the
GrandChildProperty is never set in line 9 of ChildThing. Visual Studio
2005 IntelliSense says that the instance is GrandChildThing, but there
are no properties in the propInfos count and the property is never
set. Why?
public class BaseThing
{
public string ThingOutput;
}
public class ChldThing : BaseThing
{
internal void DoSomething()
{
string yes="yes";
PropertyInfo[] propInfos = this.GetType().GetProperties(); // count is
zero
foreach (PropertyInfo propertyInfo in this.GetType().GetProperties())
{
if ( propertyInfo.Name == "GrandChildProperty")
{
XmlDocument grandchildXml = new XmlDocument();
propertyInfo.SetValue( this , grandchildXml , null );
}
}
}
}
public class GrandChildThing : ChildThing
{
public XmlDocument GrandChildProperty;
public Work()
{
base.DoSomething();
}
}