c# find element in list
C#[Edit]
+
0
-
0
c# find element in List
1 2 3 4List<string> list = new List<string> { "A1", "A2", "B1" }; string item = "A2"; bool result = list.Contains(item); // True
[Edit]
+
0
-
0
c# find element in List
1 2 3 4List<string> list = new List<string> { "A1", "A2", "B1" }; string search = "A2"; int result = list.IndexOf(search); // 1
[Edit]
+
0
-
0
c# find element in List
1 2 3 4List<string> list = new List<string> { "A1", "A2", "B1" }; string item = "A2"; int result = list.FindIndex(x => x == item); // 1
[Edit]
+
0
-
0
c# find element in List
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15using System; using System.Collections.Generic; public class Program { public static void Main() { List<string> list = new List<string> { "A1", "A2", "B1" }; string item = "A2"; bool result = list.Contains(item); Console.WriteLine(result); // True } }
[Edit]
+
0
-
0
c# find element in List
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15using System; using System.Collections.Generic; public class Program { public static void Main() { List<string> list = new List<string> { "A1", "A2", "B1" }; string search = "A2"; int result = list.IndexOf(search); Console.WriteLine(result); // 1 } }
[Edit]
+
0
-
0
c# find element in List
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15using System; using System.Collections.Generic; public class Program { public static void Main() { List<string> list = new List<string> { "A1", "A2", "B1" }; string item = "A2"; int result = list.FindIndex(x => x == item); // 1 Console.WriteLine(result); } }