Syntax Question?

Discussion in 'ASP .Net' started by N. Demos, Jun 18, 2005.

  1. N. Demos

    N. Demos Guest

    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.
    N. Demos, Jun 18, 2005
    #1
    1. Advertising

  2. N. Demos

    Brock Allen Guest

    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
    Brock Allen, Jun 18, 2005
    #2
    1. Advertising

  3. 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.
    >
    =?Utf-8?B?RGF2aWQgQW50b24=?=, Jun 18, 2005
    #3
  4. N. Demos

    N. Demos Guest

    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.
    N. Demos, Jun 18, 2005
    #4
  5. N. Demos

    N. Demos Guest

    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.
    N. Demos, Jun 18, 2005
    #5
  6. 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
    Craig Deelsnyder, Jun 19, 2005
    #6
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. gabriele renzi
    Replies:
    2
    Views:
    202
    gabriele renzi
    Dec 31, 2005
  2. Ken Bloom
    Replies:
    3
    Views:
    206
  3. Good Night Moon
    Replies:
    9
    Views:
    280
    Rick DeNatale
    Jul 25, 2007
  4. Jacob Grover
    Replies:
    5
    Views:
    310
    Jacob Grover
    Jul 18, 2008
  5. Mark Richards
    Replies:
    3
    Views:
    310
    Tad McClellan
    Nov 18, 2007
Loading...

Share This Page