i'm trying to find the first string in a list that starts between E to M (E-M);
startIndexOfMiddleRange = list.IndexOf(list.FirstOrDefault(x => x.Name.StartsWith(())))
what is the pattern or the way i should do that?
thanks for the helpers
i'm trying to find the first string in a list that starts between E to M (E-M);
startIndexOfMiddleRange = list.IndexOf(list.FirstOrDefault(x => x.Name.StartsWith(())))
what is the pattern or the way i should do that?
thanks for the helpers
 
    
    Regex solution:
^[E-M] - This pattern should work.
^ means "starts with"[E-M] limits the range to E-M, and since you're not using any modifiers on it, it will only select a single character.That being said, using regular expressions for this seems like overkill when you could simply do:
startIndexOfMiddleRange = list.IndexOf(list.FirstOrDefault(x => x.Name.Length > 0 && x.Name[0] >= 'E' && x.Name[0] <= 'M'));
Assuming list is a List<T>, you could simplify it more:
startIndexOfMiddleRange 
    = list.FindIndex(x => x.Name.Length > 0 && x.Name[0] >= 'E' && x.Name[0] <= 'M');
