国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > .NET > 正文

.Net的Collection類的一些使用說明

2024-07-10 12:56:56
字體:
供稿:網(wǎng)友
在沒有今天的研究之前,我一直以為collection類里面只有arraylist和hashtable是有用的。今天早上大起看了書以后,對(duì)collection類有了更深的了解。其中以下的代碼將是vb和c#穿插著講。因?yàn)楸救薱#和vb都會(huì),由于有些函數(shù)c#功能不是很好,所以使用了vb。

1:collection的當(dāng)家花旦當(dāng)然是數(shù)組咯。。數(shù)組的定義方法為:

int[] int_array=new int[10]

int[] myintarray = new int[5] { 1, 2, 3, 4, 5 };
上面兩句話,我就不多做解釋了。

2:結(jié)構(gòu)體在數(shù)組中的使用,代碼如下:

創(chuàng)建一個(gè)類:

class test
{
public string str_name;
public string str_phone;
}
對(duì)該類的引用和使用:

test[] mytest=new test[3];
for(int i=0;i<mytest.length;i++)
{
mytest[i]=new test();
}
mytest[0].str_name="hello";
mytest[1].str_name=" world!";
mytest[0].str_phone="hahah";

3:arraylist

arraylist我就不多說了,反正他最大的特點(diǎn)就是排序。

4:hashtable

hashtable的缺點(diǎn)就是不支持排序。很遺憾,另外在c#里根據(jù)key取value很麻煩。

5:sortedlist

sortedlist的使用方法和arraylist的使用方法差不多,只是sortedlist自動(dòng)排序。

6:stack

dim st as new stack
st.push("aa")
st.push("bb")

stack是對(duì)仗,按照是先進(jìn)后出的原則

7:queue

dim myque as new system.collections.queue
myque.enqueue("aa")

queue于stack剛剛相反,queue是先進(jìn)先出的原則來的。

8:specialized

specialized下面有好多實(shí)力,自己去用一下就ok了。

9:枚舉vb和c#示例:

vb:

dim ie as system.collections.ienumerator = al.keys.getenumerator
dim str as string = ""
while (ie.movenext)
str += ie.current
end while

c#:

system.collections.ienumerator ie=sl.keys.getenumerator();
string str="";
while(ie.movenext())
{
str+=ie.current.tostring();
}



發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 闻喜县| 迁安市| 大埔区| 神池县| 盐边县| 永靖县| 阳山县| 车险| 南昌县| 江安县| 大悟县| 丰城市| 新沂市| 屏南县| 赤壁市| 盘锦市| 区。| 霍林郭勒市| 阿坝县| 翁源县| 香格里拉县| 茶陵县| 朝阳市| 佛冈县| 老河口市| 清河县| 长春市| 安丘市| 宽城| 吉木萨尔县| 汉沽区| 南投县| 奈曼旗| 微山县| 柳林县| 鄯善县| 隆安县| 萝北县| 正镶白旗| 新绛县| 霍林郭勒市|