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));
}
}
我没用过变长数组这个东西困扰我好几天了,谢谢各位大哥,在网上搜个相关的概念,还是不明白阿
{
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));
}
}
我没用过变长数组这个东西困扰我好几天了,谢谢各位大哥,在网上搜个相关的概念,还是不明白阿
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});
}
}
有什么问题吗?看看vgctrl40和SelectedTextList的定义代码就可以了。
我的例子实现了什么功能?我不明白
{
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));
}
}