using System; using System.Linq; class Program { static void Main() { string[] array1 = { "dot", "net", "perls" }; string[] array2 = { "a", "different", "array" }; string[] array3 = { "dot", "net", "perls" }; string[] array4 = { "DOT", "NET", "PERLS" }; bool a = array1.SequenceEqual(array2); bool b = array1.SequenceEqual(array3); bool c = array1.SequenceEqual(array4, StringComparer.OrdinalIgnoreCase); Console.WriteLine(a); Console.WriteLine(b); Console.WriteLine(c); } }
False True True
string[] names = { "Niladri", "Arina", "Bob","Foo", "Bar" }; Random random = new Random(DateTime.Now.Millisecond); string name = names.ElementAt(3); Console.WriteLine("The name chosen is '{0}'.", name); /* This code produces the following sample output: The name chosen at random is 'Foo'. */