Z
zlf
Hi,
I am trying to access private field by code below. But it runs with
error.
Please tell me what's the problem or any method that may allow me to
access private field. Thank you
class Love
{
private string Name;
}
Love love = new Love();
Type type = love.GetType();
Object obj = type.InvokeMember(null,
BindingFlags.DeclaredOnly |
BindingFlags.Public |
BindingFlags.NonPublic |
BindingFlags.Instance |
BindingFlags.CreateInstance, null, null, args);
string
str=(string)type.InvokeMember("Name",BindingFlags.GetProperty,null,obj,null);
I am trying to access private field by code below. But it runs with
error.
Please tell me what's the problem or any method that may allow me to
access private field. Thank you
class Love
{
private string Name;
}
Love love = new Love();
Type type = love.GetType();
Object obj = type.InvokeMember(null,
BindingFlags.DeclaredOnly |
BindingFlags.Public |
BindingFlags.NonPublic |
BindingFlags.Instance |
BindingFlags.CreateInstance, null, null, args);
string
str=(string)type.InvokeMember("Name",BindingFlags.GetProperty,null,obj,null);