PropertyInfo.GetValue 用索引化属性的可选索引值返回该属性的值。
public virtual Object GetValue(
Object obj,
Object[] index)
如
string sre= "abcdefgh";
PropertyInfo pinfo = typeof(string).GetProperty("Chars");
object[] indexArgs = { 6 };
object value = pinfo.GetValue(str, indexArgs);
Console.WriteLine(value);
for (int x = 0; x < test.Length; x++)
{
Console.Write(pinfo.GetValue(test, new Object[] {x}));
}
public virtual Object GetValue(
Object obj,
Object[] index)
如
string sre= "abcdefgh";
PropertyInfo pinfo = typeof(string).GetProperty("Chars");
object[] indexArgs = { 6 };
object value = pinfo.GetValue(str, indexArgs);
Console.WriteLine(value);
for (int x = 0; x < test.Length; x++)
{
Console.Write(pinfo.GetValue(test, new Object[] {x}));
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货