I am coding in C# 1.1.
I want a way to find out all the ‘If’ clause without the its ‘else’ clause. Is there any easy way?
I am asking this question because I got a project source file from my client which has many IF clause that doesnt have a ELSE clause. This is causing a lot of bugs. So, I want to scan my source file to see if there is any IF clause that doesn’t have a ELSE clause.
thanks
I think you’ll probably need to use a stack because an if could be inside another if. Every time you find an if, push onto the stack. Now look for the end of the phrase. That means either a ; or matching curly braces. After that, check for else. Pop the stack.