Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
15
Task/Search-a-list/C-sharp/search-a-list.cs
Normal file
15
Task/Search-a-list/C-sharp/search-a-list.cs
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
class Program {
|
||||
static void Main(string[] args) {
|
||||
List<string> haystack = new List<string>() { "Zig", "Zag", "Wally", "Ronald", "Bush", "Krusty", "Charlie", "Bush", "Bozo" };
|
||||
|
||||
foreach (string needle in new string[] { "Washington", "Bush" }) {
|
||||
int index = haystack.IndexOf(needle);
|
||||
|
||||
if (index < 0) Console.WriteLine("{0} is not in haystack",needle);
|
||||
else Console.WriteLine("{0} {1}",index,needle);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue