2011-09-07 44 views
0

我现在有这样node[1][1]数组一些对象,存在多个子对象/每个家长如变量... node[1][2]node[1][3]等。有没有办法绑定数组子对象?

也有多个父objetcs如.. node[2][1]node[3][1]等..

我想要做的是绑定/显示ListBox中的所有子对象的所有家长

如..​​

我做了一些RESE拱,但无法找到任何方式来做到这一点?

任何帮助,将不胜感激。

+0

何人下投票, 请解释。 – Rhys

回答

0

我找到了我自己的解决方案。使用的foreach然后if语句查找并显示specfic元素

示例代码* ** * ** * ** * ** * ** * *

// statements_foreach_arrays.cs 
// Using foreach with arrays 
using System; 
class MainClass 
{ 
    public static void Main() 
    { 
     int odd = 0, even = 0; 
     int[] arr = new int [] {0,1,2,5,7,8,11}; 

     foreach (int i in arr) 
     { 
     if (i%2 == 0) 
      even++;  
     else 
      odd++;   
     } 

     Console.WriteLine("Found {0} Odd Numbers, and {1} Even Numbers.", 
         odd, even) ; 
    } 
} 

Using foreach with Arrays

相关问题