How to get first letter of each word in a string with C#

1 Answer

0 votes
using System;
using System.Linq;

class Program
{
    static void Main() {
        string str = "C# is a general-purpose multi-paradigm programming language";
        
        string firstletters = string.Join(" ", str.Split(' ').ToList().ConvertAll(word =>word.Substring(0, 1)));

        Console.Write(firstletters);
    }
}




/*
run:

C i a g m p l

*/

 



answered Jun 21, 2022 by avibootz
...