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

首頁 > 學院 > 開發設計 > 正文

c# arraylist functions

2019-11-18 17:17:51
字體:
來源:轉載
供稿:網友

When you put then in the array list you could check to see if the item already exists.  This code snippet will check to see if the string is already in the array and will only add it when the item doesn't already exist in the list.

static void Main( string[] args )
{
 ArrayList list = new ArrayList();

 AddToList( list, "Table1" );
 AddToList( list, "Table4" );
 AddToList( list, "Table1" );
 AddToList( list, "Table3" );
 AddToList( list, "Table2" );
 AddToList( list, "Table2" );

foreach ( string s in list ) //this will loop the collection to show there are no duplicates
 {
  Console.WriteLine( s );
 }
}

PRivate static void AddToList( ArrayList list, string p )
{
 if ( list.Contains( p ) == false )
  list.Add( p );
}


 


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 淅川县| 资兴市| 姚安县| 盐源县| 巧家县| 泽库县| 安宁市| 威信县| 桦南县| 玛曲县| 友谊县| 壤塘县| 涞水县| 黑水县| 都兰县| 福建省| 沈阳市| 乌拉特后旗| 阿鲁科尔沁旗| 武威市| 宜兰县| 二连浩特市| 山阳县| 来凤县| 滁州市| 黑山县| 花莲市| 金溪县| 博罗县| 永登县| 东乌| 长白| 离岛区| 海阳市| 洪江市| 宜丰县| 德钦县| 瑞昌市| 博湖县| 三河市| 大丰市|