List中Indexof用法(判断是否存在)

string str = "aa";
ArrayList list = new ArrayList();
list.Add("bb");
list.Add("aa");
list.Add("cc");
if (list.IndexOf(str) == -1)
{
list.Add(str);
}

posted @ 2016-10-10 13:28  开开123  阅读(16085)  评论(0编辑  收藏  举报