object o = new object[] { new object[] { "a", "test1" }, new object[] { "b", "test2" } }; string s = ((o as object[])[0] as object[])[1].ToString();这样能获取到s值是test1啊
((result as object[])[0] as object[])[0] ((result as object[])[0] as object[])[1] 这两句都会返回null
object o = new object[] { new object[] { "a", "b" }, new object[] { "aa", "bb" } }; object a = ((o as object[])[0] as object[])[1];这样也能获取到这个对象哦
我从即时窗口得到的信息 result {object[1]} [0]: Count = 2 (result as object[])[0] Count = 2 [0]: {[key1, test1]} [1]: {[key2, test2]} ((result as object[])[0] as object[])[0] “(result as object[])[0] as object[]”为 null ((result as object[])[0] as object[])[1] “(result as object[])[0] as object[]”为 null
((result as object[])[1] as object[])[0] ((result as object[])[1] as object[])[1]这样试试
object[] o = new object[] { new object[] { "a", "test1" }, new object[] { "b", "test2" } };
foreach (var item in o) { string s = ((item as object[])[0]).ToString();
}
((result as object[])[1] as object[])[0] 数组索引超出界限 ((result as object[])[1] as object[])[1] 数组索引超出界限
Type mytype = obj.GetType(); PropertyInfo[] pinfo = mytype.GetProperties(); foreach(PropertyInfo item in pinfo) { //value是取出值要放到的变量 value =item.getValue(obj,null); }
((result as object[])[0] as object[])[1]
这两句都会返回null
谢谢你啊,我只需要取到object就行了,因为后面我要自己遍历,不需要取key的实际值
谢谢关注,你这个是自己建的object我的object是从web服务取得的,好像不太一样,他后面还有count属性
result
{object[1]}
[0]: Count = 2
(result as object[])[0]
Count = 2
[0]: {[key1, test1]}
[1]: {[key2, test2]}
((result as object[])[0] as object[])[0]
“(result as object[])[0] as object[]”为 null
((result as object[])[0] as object[])[1]
“(result as object[])[0] as object[]”为 null
((result as object[])[1] as object[])[1]这样试试
foreach (var item in o)
{
string s = ((item as object[])[0]).ToString();
}
((result as object[])[1] as object[])[0]
数组索引超出界限
((result as object[])[1] as object[])[1]
数组索引超出界限
Type mytype = obj.GetType();
PropertyInfo[] pinfo = mytype.GetProperties();
foreach(PropertyInfo item in pinfo)
{
//value是取出值要放到的变量
value =item.getValue(obj,null);
}