有没有办法绑定数组的子对象?

本文关键字:对象 数组 绑定 有没有 | 更新日期: 2023-09-27 18:08:03

我目前有一些对象在这样的数组node[1][1],有多个子对象/每个父变量,例如…node[1][2], node[1][3]

也有多个父对象,例如…node[2][1], node[3][1]

我要做的是绑定/显示列表框中所有父对象的所有子对象

如. .listBox1.itemsource = node[All][1];

我做了一些研究,但找不到任何方法来做到这一点?

任何帮助都会很感激。

有没有办法绑定数组的子对象?

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

<<p>例子代码strong> * * * * * * * * * * * * * * * * *
// 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) ;
   }
}