Function Kata „LOC“
Implement a function that counts the Lines of Code (LOC) in a C# source text.
The source text is given as a string. The function returns the number of executable lines of code. Lines containing only comments or whitespace should be filtered .
- C# has no nested comments
- Comment characters –/*, */, //– don’t open/close comments inside of strings
- Strings inside comments are not recognized. That means, the comment /*a“*/“b… ends in front of „b.
- Executable code can be placed in the same line as a comment: in front of /* or // or after */.
Also return the number of lines that contain only comments or whitespace.
 Strings count as executable code. Even if they extend over multiple lines or contain whitespace lines.
“I am the founder of Majer Consulting and Majer Training and an experienced software developer, trainer and consultant. I have been on the road in the SAP world since 1998, supporting numerous projects, and have developed a passion for software engineering, software testing and agile development methods such as TDD. When I am not servicing customers or holding seminars, I am speaking at conferences or writing my next book.”