473,473 Members | 1,888 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Syntax Question?

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.
Nov 19 '05 #1
5 1160
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


Nov 19 '05 #2
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.

Nov 19 '05 #3
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.
Nov 19 '05 #4
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.
Nov 19 '05 #5
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
Nov 19 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

699
by: mike420 | last post by:
I think everyone who used Python will agree that its syntax is the best thing going for it. It is very readable and easy for everyone to learn. But, Python does not a have very good macro...
4
by: Aaron Walker | last post by:
Greetings, I'm attempting to write my first *real* template function that also deals with a map of strings to member function pointers that is making the syntax a little tricky to get right. ...
2
by: bor_kev | last post by:
Hi, First of all, i want to use the new managed class syntax and STL.NET under Microsoft Visual (C++) Studio 2005 Beta. I read in a Microsoft...
5
by: r.nikhilk | last post by:
Hi, Currently, we are porting C++ applications from 32 bit to 64 bit on AIX platform. (The current version of AIX is 5.3 and xlC verison is 8.0). We are able to compile the applications by...
3
by: astromog | last post by:
I have some significantly extended syntax for Python that I need to create a reference implementation for. My new syntax includes new keywords, statements and objects that are sort of like classes...
11
by: deppy_3 | last post by:
Hi! The syntax of fputs() is similar with the syntax of fgets(); For example if we have:fgets(str,maxlen,stdin) which is the syntax of the fputs();
8
by: Smithers | last post by:
Are there any important differences between the following two ways to convert to a type?... where 'important differences' means something more profound than a simple syntax preference of the...
2
by: berrylthird | last post by:
This question was inspired by scripting languages such as JavaScript. In JavaScript, I can access members of a class using array syntax as in the following example: var myInstance:myClass = new...
17
by: trose178 | last post by:
Good day all, I am working on a multi-select list box for a standard question checklist database and I am running into a syntax error in the code that I cannot seem to correct. I will also note...
6
by: Daniel | last post by:
I hope this question is OK for this list. I've downloaded Rpyc and placed it in my site packages dir. On some machines it works fine, on others not so much. Here is one error I get when I try...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.