How to find the first element 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" };

        var result = Array.Find(arr, element => element.StartsWith("p")); 

        Console.Write(result);
    }
}



/*
run:

python

*/

 



answered Nov 2, 2020 by avibootz
...