J Jacek Jurkowski Mar 7, 2005 #1 String[] s = new String[]{"a","b","c","d"}; What is the simpliest way to check if s contains value "c"?
String[] s = new String[]{"a","b","c","d"}; What is the simpliest way to check if s contains value "c"?
S Stefan Simek Mar 7, 2005 #2 Jacek said: String[] s = new String[]{"a","b","c","d"}; What is the simpliest way to check if s contains value "c"? Click to expand... Array.IndexOf(s, "c") != -1 HTH, Stefan
Jacek said: String[] s = new String[]{"a","b","c","d"}; What is the simpliest way to check if s contains value "c"? Click to expand... Array.IndexOf(s, "c") != -1 HTH, Stefan
D Dennis Myrén Mar 7, 2005 #3 Use System.Array.IndexOf(or System.Array.BinarySearch, depending on the context). Example: public static bool ArrayContains ( string [] array, string value ) { return System.Array.IndexOf(array, value) > -1; }
Use System.Array.IndexOf(or System.Array.BinarySearch, depending on the context). Example: public static bool ArrayContains ( string [] array, string value ) { return System.Array.IndexOf(array, value) > -1; }