Relative Content

Tag Archive for c#stringindexingmax

Searching for an Integer with the highest index within a string – C#

String[] digits = { “0”, “1”, “2”, “3”, “4”, “5”, “6”, “7”, “8”, “9” }; String line = “four95qvkvveight5”; index_digit2 = digits .Where(d => line.Contains(d)) .Max(d => line.IndexOf(d)); I am iterating over a file searching for the first and the last digit in each line. This is what I’m using to search for the last […]