Solved

Optimize Code By Commenting Out Blank Lines?

Posted on 2004-08-18
3
167 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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
VB.NET - Extract Pairs out of a string (JSON) 4 33
Total in textboxes 9 36
Code enhancement 5 14
Events in static methods 3 31
Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

743 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

11 Experts available now in Live!

Get 1:1 Help Now