/// 可赋值 ///
赞
踩
数据类:
public class TestVaule
{
/// <summary>
/// 不可赋值
/// </summary>
public string m_Value1 { get { return "111"; } }
/// <summary>
/// 可赋值
/// </summary>
public string m_Value2 { get; private set; }
/// <summary>
/// 可赋值
/// </summary>
public string m_Value3
{
get { return m_Value3; }
set { m_Value3 = value; }
}
}
测试类:
void Start()
{
TestVaule mm = new TestVaule();
Type T = mm.GetType();
var FileSingleInfo = T.GetProperty("m_Value1", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);
string Temp = "ppp";
//这里是无法赋值的,但是可以获取,m_Value2 m_Value3 均可以通过GetValue,及SetValue 赋值
FileSingleInfo.SetValue(mm, Temp);
}
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。