Answer: The ElementAt operator retrieves the element at a given index in the collection.
e.g.
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'.
*/
Asked In: Many Interviews |
Alert Moderator