neel ajay neel ajay - 8 months ago 18
C# Question

Searching in string array to get list of specifc values starting with speacific charecter ?How to

This is my string array

"Ararangua AAA", "LOS-Lagos LOS", "ARRABURY QL AUSTRALIA AAB", "Babrey BSA" , "lahore LHE"

i am performing search on it that all values out of 199989 string values that start with charecter 'a' or 'A' must be returned in another array of string my value to be searhed is at 1 index can you tell me any other simple mechanism to get the array of string only those who start with a

for (int i = 0; i <= arr.Length; i++)
char c = arr[0][1];



can be done in LINQ.somthing like this

string contents = "\"Ararangua  AAA\",\"LOS-Lagos LOS\", \"ARRABURY QL AUSTRALIA  AAB\"";

    var data =  (from a in contents.Split(',')
                 let t = a.Replace("\"",string.Empty).Trim()
                 where t[0] =='a' || t[0] =='A'
                 select t).ToArray();