Console.WriteLine(ArrayList的)错误的输出 [英] Console.WriteLine(ArrayList) wrong output
本文介绍了Console.WriteLine(ArrayList的)错误的输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我要打印的各种foreach循环的ArrayList的,但我唯一得到的内容是字符串+ System.Collections.ArrayList。
I'm trying to print the content of the ArrayList of the various foreach loops but the only thing i get is the String + System.Collections.ArrayList.
例如下面的code:
ArrayList nodeList = new ArrayList();
foreach (EA.Element element in elementsCol)
{
if ((element.Type == "Class") || (element.Type == "Component") || (element.Type == "Package"))
{
nodeList.Add(element);
}
Console.WriteLine("The nodes of MDG are:" + nodeList); //stampato a schermo la lista dei nodi nel MDG finale
和我得到的输出是:
千年发展目标的节点是:System.Collections.ArrayList
能否请人告诉我为什么?
Can please someone tell me why?
推荐答案
在通过ArrayList中必须循环得到它的价值...
you have to loop through the arraylist to get its value...
foreach(var item in nodeList)
{
Console.WriteLine("The nodes of MDG are:" + item);
}
这将工作..
更新:
使用元素而不是节点列表
Use element instead of nodelist
Console.WriteLine("The nodes of MDG are:" + element);
这篇关于Console.WriteLine(ArrayList的)错误的输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文