If I have the following array of strings:
string[] stringArray = {\"one\", \"two\", \"three\", \"four\"};
Is there a way to get the first and l
First
Console.WriteLine(stringArray.First());
Console.WriteLine(stringArray.ElementAt(0));
Console.WriteLine(stringArray[0]);
var stringEnum = stringArray.GetEnumerator();
if (stringEnum.MoveNext())
Console.WriteLine(stringEnum.Current);
Last
Console.WriteLine(stringArray.Last());
if (stringArray.Any())
Console.WriteLine(stringArray.ElementAt(stringArray.Count()-1));
Console.WriteLine(stringArray[stringArray.Length -1]);
var stringEnum = stringArray.GetEnumerator();
string lastValue = null;
while (stringEnum.MoveNext())
lastValue = (string)stringEnum.Current;
Console.WriteLine(lastValue);