How to find all 2 or 3 letters words from a list in C#

1 Answer

0 votes
using System;
using System.Linq;
using System.Collections.Generic;

public class Program
{
    public static void Main(string[] args)
    {
        List<string> lst = new List<string> { "python", "c", "c++", "c#", "java", "php", "nodejs", "ada", "go" };

        List<string> threeLetter_words = lst.Where(word => word.Length == 2 || word.Length == 3).ToList();

        Console.WriteLine(string.Join(", ", threeLetter_words));
    }
}
 
 
 
/*
run:
   
c++, c#, php, ada, go
   
*/

 



answered Jun 21, 2024 by avibootz

Related questions

1 answer 143 views
1 answer 119 views
1 answer 103 views
1 answer 98 views
1 answer 106 views
...