private void GetSelectedTextList(vgctrl40.IUnit O)
 {
int i;
vgctrl40.IElement E;
if (O.ClassId == 1)     //   '  -------- 如果是"Text" --------
SelectedTextList.Add(O);   
else if(O.ClassId == 99)
{  //   '  -------- 如果是元件 --------
E =(vgctrl40.IElement) O;
if(E.IsCombined())
for(i = 0;i<E.UnitCount;i++)
GetSelectedTextList(E.get_Units(i));
}
}
我没用过变长数组这个东西困扰我好几天了,谢谢各位大哥,在网上搜个相关的概念,还是不明白阿

解决方案 »

  1.   

    SelectedTextList是个ArrayList或List吧,是能够自动增加的动态数组。
      

  2.   

    数组可以是一维的,也可是多维的。数祖的成员可以是整齐的,也可以是变长(jagged)的。 一维的数组是最普通,最简单的。这里值给出一个例子,就不多解释了。*/ 
    using System; 
    class Test 

     static void Main() { 
      int[] arr = new int[5]; 
      for (int i = 0; i < arr.Length; i++) 
       arr[i] = i * i; 
      for (int i = 0; i < arr.Length; i++) 
       Console.WriteLine("arr[{0}] = {1}", i, arr[i]); 
     } 
    } /* 结果如下: 
    arr[0] = 0 
    arr[1] = 1 
    arr[2] = 4 
    arr[3] = 9 
    arr[4] = 16 我们还可以比较的看看多维,规则,变长的数组的定义和赋值:*/ 
    class Test 

     static void Main() { 
      int[] a1 = new int[] {1, 2, 3};                     //一维 
      int[,] a2 = new int[,] {{1, 2, 3}, {4, 5, 6}};      //二维 
      int[,,] a3 = new int[10, 20, 30];                   //三维 
      int[][] j2 = new int[3][];                          //变长 
      j2[0] = new int[] {1, 2, 3}; 
      j2[1] = new int[] {1, 2, 3, 4, 5, 6}; 
      j2[2] = new int[] {1, 2, 3, 4, 5, 6, 7, 8, 9}; 
     } 

    /* 
    上面的例子给出了各种样式的数组。变量a1、a2和a3是规则数组。j2则是变长的数组。 
    规则数组很容易就可以计算出它们的长度。比如a3的长度是:10*20*30=6000。相反,变长 
    数组就有点不同,它的每一个维度都必须单独定义。如j2的第一维度是3,第二个是6,第 
    三个是9,所以总长度是:1*3+1*6+1*9=18。 上面对数组的赋值是严谨的风格,在某种情况下,我们可以简化写法,但我总觉得这种简化 
    应用限制太多,容易出错。在这里就不作介绍了。这里再给一个例子说明函数中的参数如何 
    赋值*/ 
    class Test 

     static void F(long[] arr) {} 
     static void Main() { 
      F(new longt[] {1, 2, 3}); 
     } 
    }
      

  3.   

    有什么问题吗?看看vgctrl40和SelectedTextList的定义代码就可以了。
      

  4.   

    // livode(啊水) 
     
       有什么问题吗?看看vgctrl40和SelectedTextList的定义代码就可以了。
      
     我的例子实现了什么功能?我不明白
      

  5.   

    一个递归的算法private void GetSelectedTextList(vgctrl40.IUnit O)
     {
    int i;
    vgctrl40.IElement E;
    if (O.ClassId == 1)     // 如果是"Text" , 添加到SelectedTextList
    SelectedTextList.Add(O);  
    else if(O.ClassId == 99)
    {  //  如果是元件 ,取出元件中的units, E.get_Units(i)返回的就是vgctrl40.IUnit
    E =(vgctrl40.IElement) O;
    if(E.IsCombined())
    for(i = 0;i<E.UnitCount;i++)
    GetSelectedTextList(E.get_Units(i));
    }
    }
      

  6.   

    这个应该是绘图软件中的一部分,处理的内容是取出所有的IUnit对象的text,用递归算法
      

  7.   

    用递归算法取出IUnit的Text放到一个ArrayList中
      

  8.   

    反正就是把全部IUnit的Text放进ArrayList...
      

  9.   

    看得像递归。不过vgctrl40.IUnit 是什么就没有看懂,所以基本不懂,呵呵!!
      

  10.   

    vgctrl40.IElement E; C支持这种声明吗?还有 E O,变量名取得也垃圾,明显是个SB写出来的程序