What is simpliest way to get Line number from char position in String in C#? (or get Position of line (first char in line) ) Is there any built-in function ? If there are n
Count the number of newlines in the substringed input string.
var lineNumber = input.Substring(0, pos).Count(c=>c == '\n') + 1;
edit: and do a +1 because line numbers begin at 1 :-)
+1