Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Syntax Question?

Reply
Thread Tools

Syntax Question?

 
 
N. Demos
Guest
Posts: n/a
 
      06-18-2005
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


--
Change "seven" to a digit to email me.
 
Reply With Quote
 
 
 
 
Brock Allen
Guest
Posts: n/a
 
      06-18-2005
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.

-Brock
DevelopMentor
http://staff.develop.com/ballen



> 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




 
Reply With Quote
 
 
 
 
=?Utf-8?B?RGF2aWQgQW50b24=?=
Guest
Posts: n/a
 
      06-18-2005
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. Demos" wrote:

> 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
>
>
> --
> Change "seven" to a digit to email me.
>

 
Reply With Quote
 
N. Demos
Guest
Posts: n/a
 
      06-18-2005
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


--
Change "seven" to a digit to email me.
 
Reply With Quote
 
N. Demos
Guest
Posts: n/a
 
      06-18-2005
N. Demos wrote:

> 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


--
Change "seven" to a digit to email me.
 
Reply With Quote
 
Craig Deelsnyder
Guest
Posts: n/a
 
      06-19-2005
N. Demos wrote:
> N. Demos wrote:
>
>> 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
>
>


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'

--
Craig Deelsnyder
Microsoft MVP - ASP/ASP.NET
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Syntax Checker that's better than the normal syntax checker Jacob Grover Ruby 5 07-18-2008 05:07 AM
Syntax error? What syntax error? Assignment fo default values? Mark Richards Perl Misc 3 11-18-2007 05:01 PM
Syntax bug, in 1.8.5? return not (some expr) <-- syntax error vsreturn (not (some expr)) <-- fine Good Night Moon Ruby 9 07-25-2007 04:51 PM
[ANN] SqlStatement 1.0.0 - hide the syntax of SQL behind familiarruby syntax Ken Bloom Ruby 3 10-09-2006 06:46 PM
Syntax highligth with textile: Syntax+RedCloth ? gabriele renzi Ruby 2 12-31-2005 02:44 AM



Advertisments