Solved

Optimize Code By Commenting Out Blank Lines?

Posted on 2004-08-18
3
168 Views
Last Modified: 2010-04-23
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?
0
Comment
Question by:dbnewbie
3 Comments
 
LVL 11

Expert Comment

by:saleek
ID: 11839766
Hi,

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

regards,

KS
0
 
LVL 69

Accepted Solution

by:
Éric Moreau earned 50 total points
ID: 11842317
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
 

Author Comment

by:dbnewbie
ID: 11857829
I used ILDASM and noticed no difference. Thanks.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now