How to get the length of every word in array of strings using Linq in C#

1 Answer

0 votes
using System;
using System.Linq;

class Program
{
    static void Main() {
        string[] array = { "c sharp", "c", "c++", "java", "python" };
        
        var wordsLength = array.Select(e => e.Length);
        
        Console.WriteLine(string.Join(", ", wordsLength));
    }
}



/*
run:

7, 1, 3, 4, 6

*/

 



answered Jul 3, 2023 by avibootz
...