开发者

Is there a way to bind an arrays child objects?

I current have some objects in an array l开发者_如何转开发ike this node[1][1], there are multiple child objects/variables for each parent eg.. node[1][2], node[1][3] etc..

There are also multiple parent objetcs eg.. node[2][1], node[3][1] etc..

What I want to do is bind/Display all child objects in a listbox from all parents

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

I have done some research but can't find any way to do this?

Any help would be appreciated.


I found my own solution for this. Using foreach and then if statement to find and display specfic element

Examples Code *****************

// 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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜