(1) 第一種方法:
int[] ia = {1,2,3}; int id = Array.IndexOf(ia,1); // 這里的1就是你要查找的值 if(id==-1) // 不存在 else // 存在
(2) 第二種方法:
string[] strArr = {"a","b","c","d","e"}; bool exists = ((IList)strArr).Contains("a"); if(exists) // 存在 else // 不存在
注意: 用IList需要using System.Collections;
JS:IE8中的數組沒有indexOf這個方法,ie10有。
js:字符串轉換成數組:str.split(",");括號內按照字符串中的符號來寫
數組轉換成字符串:Array.join("#"),#代表分隔的符號