How to get words from an array of strings that contains specific letter using Linq in C#

1 Answer

0 votes
using System;
using System.Linq;

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

        var result = array.Where(word => word.Contains('a'));
    
        foreach (var word in result) {
            Console.WriteLine(word);
        }
    }
}



/*
run:

java
c sharp
javascript

*/

 



answered Jul 2, 2023 by avibootz
...