How to find all the elements in string array that starts with specific character in C#

1 Answer

0 votes
using System;
 
class Program
{
    static void Main() {
    
        string[] arr = { "c#", "java", "python", "swift", "php" };
 
        string[] result = Array.FindAll(arr, element => element.StartsWith("p")); 
 
        foreach (string s in result) {           
            Console.WriteLine(s);
        }
    }
}
 
 
 
/*
run:
 
python
php
 
*/

 



answered Nov 2, 2020 by avibootz
...