C#的ArrayList提供了一个专用的Contains方法来检测ArrayList是否包含指定的对象,返回值是一个bool类型
ArrayList alcollect = new ArrayList();
// Add individual items to the collection
string str = "learn csharp"; alcollect.Add(str);
//check existence codego.net/1/1/1/
of object if(alcollect.Contains(str))
{ Console.WriteLine(alcollect.IndexOf(str));
} else{
Console.WriteLine("Not found!");
}
C#的ArrayList提供了一个专用的Contains方法来检测ArrayList是否包含指定的对象,返回值是一个bool类型
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/29974986/viewspace-1563775/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/29974986/viewspace-1563775/