How to access array elements with Linq in C#

1 Answer

0 votes
using System;
using System.Linq;

class Program
{
    static void Main() {
        var array = new string[] { "c", "java", "c sharp", "c++", "python", "javascript" };

        Console.WriteLine(array.ElementAt(2));
        
        Console.WriteLine(array.First());
        Console.WriteLine(array.Last());
    }
}



/*
run:

c-sharp
c
javascript

*/

 



answered Jul 2, 2023 by avibootz

Related questions

...