I am trying to change an internal property and I am not sure what is wrong or if I am doing it correctly
this is the code for the internal property it is in a different name space and I cannot change internal to public.
csharp
namespace namespace_one
{
class Class1
{
private bool isDirty = false;
public Class1()
{
}
internal bool IsDirty
{
get { return isDirty; }
set { isDirty = value; }
}
}
}
here is my class and code trying to change it
csharp
namespace namespace_two
{
class Class2
{
private namespace_one.Class1 class1;
public Class2()
{
class1 = new namespace_one.Class1();
SetIsDirty();
}
private void SetIsDirty()
{
System.Type type = class1.GetType();
System.Reflection.FieldInfo feildInfo = type.GetField("IsDirty",
System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.NonPublic |
System.Reflection.BindingFlags.Instance);
(feildInfo.GetValue(class1) as
namespace_one.Class1).IsDirty = true;//Error 'Class1' does not contain a definition for 'IsDirty'
}
}
}
IsDirty is not in intellisense so i know I am doing it wrong.
This post has been edited by zakary: 22 May, 2008 - 11:00 AM