c# - counting occurrences of end of line -
i have string text, want count occurrences of environment.newline.
i thought in way
mystring.where(c => c == environment.newline).count(); but c 1 char not work .
any better suggestions ?
with regex:
int count = regex.matches(input, environment.newline).count; with string.split:
int count = input.split(new string[] { environment.newline }, stringsplitoptions.none).length - 1;
Comments
Post a Comment