C#中System.Object的访问数据[] [英] C# Accessing data in System.Object[]

查看:246
本文介绍了C#中System.Object的访问数据[]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我编码在C#中,我有大量数据的字典。其中一名成员是孩子,但是当我尝试写出自己的价值观,我得到:
System.Object的[]

I'm coding in C# and I have a dictionary with tons of data. One of the members is "children" but when I try to write out its values, I get: System.Object[]

我知道孩子包含数据,大概嵌套的数据,但我不能确定它是否是一个列表,字典,数组等等。

I know that children contains data, probably nested data, but I'm unsure if it's a list, dictionary, array, etc.

我如何写出来的孩子中的所有数据?

How do I write out all the data within "children"?

推荐答案

任何实例.NET类型的默认响应的ToString()是写出来的完全限定的类型名称。

The default response of any instantiated .NET type to "ToString()" is to write out the fully qualified type name.

System.Object的[]意味着你有一个数组,其中每个元素的类型是对象。这个盒子可以包含任何事情,因为在.NET中每个类型从Object派生。下面可能会告诉你什么是数组中实例化的类型看还真包括:

System.Object[] means that you have an array where each element is of type "Object". This "box" could contain anything since every type in .NET derives from Object. The following may tell you what the array really contains in terms of instantiated types:

foreach (object o in children)
  Console.WriteLine(o != null ? o.GetType().FullName : "null");

这篇关于C#中System.Object的访问数据[]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆