Syntax Question?

N

N. Demos

In the ASP.Net (VB.Net) book I'm reading (learning from) the syntax used
for class inheritance uses a colon between the class declaration and the
inheritance statement.

EX:
Public Class MyClassName : Inherits ParentClassName


Elsewhere, I have seen the following syntax without the colon operator.

Public Class MyClassName
Inherits ParentClassName

I've had no problems (that I know of) with either sytax style when
compling and running code.

Which is the correct syntax, or are both correct? Thanks for your time.

Regards,
N. Demos
 
B

Brock Allen

The ":" syntax in VB.NET is the line break (or continuation) character. VB.NET
wants Inherits on the next line, but the : is a shortcut to doing that. They
are equivalent.
 
G

Guest

It's strange - most developers (probably even the author of the book you
mention) would say that joining lines with ":" is poor style, but since the
colon is coincidentally the same operator used for signifying inheritance in
C#, many of the same developers use the line join operator there in VB
without even thinking about it.

David Anton
www.tangiblesoftwaresolutions.com
Home of:
Instant C#: VB.NET to C# Converter
Instant VB: C# to VB.NET Converter
Instant J#: VB.NET to J# Converter
 
N

N. Demos

David, Brock,
Thanks for the info. What about the old VB line continuation character
"_" (underscore). Are there two line continuation characters now?

Regards,
N. Demos
 
N

N. Demos

N. Demos said:
David, Brock,
Thanks for the info. What about the old VB line continuation character
"_" (underscore). Are there two line continuation characters now?

Regards,
N. Demos

Disregard this, I now realize these do not perform the same function.

Regards,
N. Demos
 
C

Craig Deelsnyder

N. Demos said:
Disregard this, I now realize these do not perform the same function.

Regards,
N. Demos

Yes, a little confusing :) IMHO use of : in VB.NET is poor practice as
it leads to hard-to-follow code. It's too easy to slip some code in at
the end of a line that someone else could 'skip over', as we're usually
used to 1 command per line (or 1 command split across multiple lines at
most).

Some would argue differently for such a 'minor' thing like marking
inheritance, but hey, believe me after 8 years, I live by 'practice
makes perfect' :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top