Optimize Code By Commenting Out Blank Lines?

Someone told me that commenting out blank lines in VB.NET code improves efficiency because the compiler does not have to evaluate the blank lines. For example:

MessageBox.Show("Hello world!")
'
'
'
MessageBox.Show("I commented out the blank lines.")

This sounds ridiculous to me. Blank lines in code should be ignored by the compiler -- whether or not it is commented out. Am I right?

Is there (or was there ever) a language where commenting out blank lines made a difference?
dbnewbieAsked:
Who is Participating?
 
Éric MoreauSenior .Net ConsultantCommented:
I have never saw this anywhere before.

I would say that either commented lines or empty lines are skipped the same way by the compiler so it won't change anything at compile time.

Without having tested it, I am sure that the resulting EXE or DLL will be the same.

The real test would be to generate to EXEs (one with blank lines commented out and one without) and check the file with ILDASM.
0
 
Ramesh SrinivasTechnical ConsultantCommented:
Hi,

It may do with compilers from other languages, but it certainly isnt the case with .net.

regards,

KS
0
 
dbnewbieAuthor Commented:
I used ILDASM and noticed no difference. Thanks.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.