第一种方法
int[] ia = {1,2,3};int id = Array.IndexOf(ia,1); // 这里的1就是你要查找的值if(id==-1)// 不存在else// 存在
第二种方法
string[] strArr = {\"a\",\"b\",\"c\",\"d\",\"e\"};bool exists = ((IList)strArr).Contains(\"a\");if(exists)// 存在else// 不存在
注意: 用IList需要using System.Collections;
爱站程序员基地
![(原创)[C#] 一步一步自定义拖拽(Drag&Drop)时的鼠标效果:(一)基本原理及基本实现-爱站程序员基地](https://aiznh.com/wp-content/uploads/2022/07/20220721231016-62d9dcd85c40b-220x150.gif)

