国产探花免费观看_亚洲丰满少妇自慰呻吟_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 );
}


 


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 随州市| 莱阳市| 德安县| 常宁市| 繁峙县| 河北区| 松原市| 岑溪市| 时尚| 金堂县| 宝应县| 通河县| 牡丹江市| 湖北省| 永定县| 山阴县| 德江县| 集安市| 荆门市| 永清县| 东源县| 武定县| 佳木斯市| 阳谷县| 莎车县| 汪清县| 黄大仙区| 抚松县| 乡城县| 芒康县| 叙永县| 三明市| 三河市| 措勤县| 昌乐县| 兴山县| 白山市| 玉溪市| 白水县| 文登市| 景宁|