472,126 Members | 1,540 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,126 software developers and data experts.

What the diffirence between C# and VB.net?



--
----------------
Simon Peng
xq****@tsinghua.org.cn
Nov 15 '05 #1
7 1715
There are some differences between VB.NET and C#

VB.NET doesn't support operator overloading.
VB.NET doesn't support define #region within a method body.
VB.NET doesn't support indexer.
etc.

look for details
http://www.advisor.com/Articles.nsf/aid/SHERP42
-------------------------
"Manish Agarwal"- <ma***********@hotmail.com>
http://personal.vsnl.com/mkag
If replying to the group, please do not mail me.
"Simon Peng" <xq****@tsinghua.org.cn> wrote in message
news:#F**************@tk2msftngp13.phx.gbl...


--
----------------
Simon Peng
xq****@tsinghua.org.cn

Nov 15 '05 #2
Manish,
VB.NET doesn't support indexer.


Sure it does.

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/
Please reply only to the newsgroup.
Nov 15 '05 #3
One is full of assumptions and bugs waiting to happen and the other other is
very anal/strict/less-bug-prone... :o)
"Fergus Cooney" <wo****@tesco.net> wrote in message
news:OS**************@TK2MSFTNGP10.phx.gbl...
Hi Simon,

One's Brilliant!!, the other's Great!!

Yours [unhelpfully :-)]
Fergus

Nov 15 '05 #4
I believe the syntax in VB.NET is "Default Property" as opposed to indexer,
but it's the same thing:
Default Property Item(ByVal index as Integer) As String
--
Mike Mayer
http://www.mag37.com/csharp/
mi**@mag37.com
"Mattias Sjögren" <ma********************@mvps.org> wrote in message
news:O$**************@TK2MSFTNGP09.phx.gbl...
Manish,
VB.NET doesn't support indexer.


Sure it does.

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/
Please reply only to the newsgroup.

Nov 15 '05 #5
In a nutshell, I believe VB.NET to be for a) supporting legacy VB 6 users,
and b) for rapid-application development. In versions 2002-03 of VS, I
don't see many differences in RAD between VB.NET and C#, but I believe the
next versions of the IDE will reflect a bigger difference. (Microsoft says
vb is for task-based programming, while c# is for code-based programming,
whatever that means. I only write code to perform tasks!). What I think
it means is that while the C# team worked on generics, the vb.net team
brought back edit & continue, and added some really cool error-checking as
you code. (Almost like ms word's grammar & spelling check as you type). I
already think the VB.NET IDE is much better than the C# IDE, and it is
advancing further ahead.

In addition to operator overloading and the #region within a method body
(which I didn't realize to be a difference, nor do I think to be a very good
idea), here are some other differences:

1. C# by default supports XML comments (there are currently plugins for
VB.NET xml comments, and the next version will support it natively). This
is a huge plus for C# at the moment - especially when combined with ndoc.

2. VB.NET has a simpler syntax for some event handlers (especially useful
for GUIs) since they have the keyword "handles"
e.g.
MySub(Object sender, EventArgs e) Handles Button1.Clicked
blah blah
End Sub
no need for a line Button1.Clicked += new EventHandler(MySub)

3. VB.NET is a bit more verbose in other ways, using End Sub instead of
just } - note that the IDE generally provides the End Sub / End Fucntion /
End If automagically as soon as you start a block, so you probably type
about the same amount. Implementing properties in vb.net is really easy
with the ide - it adds the get/set methods as soon as you type the property
declartion.

4. Case sensitivity - VB.NET isn't case sensitive. This has it's advantages
and disadvantages. I like this for RAD because as I'm typing (all
lowercase) I can see it automatically recase to ProperPascalCase or
camelCase. If it doesn't recase, it means I misspelled something. I don't
like the case insensitivity because I like to use case to define scope. For
instance, a public property named Color may use a private variable color,
both of type Color. In VB.NET, you're forced to name the private variable
something else, like myColor or m_Color.

5. VB.NET has support for some "archaic" vb things that you probably
shouldn't be using in new code, but that might be useful for portability.
The terrible "On Error Resume" and such is still available in VB.NET. Also
ReDim Preserve for resizing arrays and preserving the contents (which just
copies the array contents to a new array, I believe, but the syntax *may* be
cleaner). VB.NET can also define arrays to have non 0 based indices, but
these are strongly discouraged. There's an entire dll of vb things (which
are also available in C# if you need them) specifically for legacy code.

6. VB.NET has an Option Strict On/Off which changes how typesafe the
compiler forces you to be. (C# is always quite typesafe)

7. VB.NET supports optional arguments on methods.

8. C# supports unsigned integer types (you can't add two unsigned ints in
VB.NET, for instance).

9. C# supports "unsafe" code, i.e. you can still use pointers if you need.
(really useful for image manipulation).

10. ; in C# - which is REALLY NICE. Otherwise, in VB.NET, you have to use
_ when a statement runs over the end of a line, which seems to make my VB
code have really long lines that go past the end of the screen and makes the
code much harder to read.

11. The VB.NET IDE is much nicer. Especially for intellisense, trying to
override base class methods, and adding event handlers. And the
error-reporting as you code is way ahead in VB.NET.

12. Possible difference in salary of a developer (historically C++ paid more
than VB, not sure where C# will fall in the spectrum).

13. Future differences: C# will support generics, don't think VB.NET will
(soon anyways)

Finally, and probably the most important of all: C# is more familiar for
anybody who has a C/C++/Java background. VB.NET is more familiar for
anybody who has a VB background. Pick the one that fits either your past
experience or future plans (do you want to be a Java/.NET developer, C# is
probably better. Do you come from a history of VB6 / COM programming?
VB.NET will probably be better). They both have access to the entire FCL
(Framework Class Library) so things like opening a file, reading its
contents, performing a regular expression replace on the contents, and
posting the results to a web page will be virtually identical between the
two languages.

--
Mike Mayer
http://www.mag37.com/csharp/
mi**@mag37.com
Nov 15 '05 #6
Michael Mayer <mi**@mag37.com> wrote:
13. Future differences: C# will support generics, don't think VB.NET will
(soon anyways)


I believe it'll have it in the same release that C# does. From
http://msdn.microsoft.com/vstudio/pr...p.aspx#whidbey

<quote>
Finally, for the more advanced Visual Basic developer, language
enhancements include support for operator overloading, unsigned data
types, inline XML-based code documentation, and partial types. In
addition, developers using Visual Basic will have access to a type-
safe, high-performance, compile time-verified version of generics that
promote code reuse across a variety of data types.
</quote>

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet/
If replying to the group, please do not mail me too
Nov 15 '05 #7
"Jon Skeet" <sk***@pobox.com> wrote in message
news:MP***********************@news.microsoft.com. ..
Michael Mayer <mi**@mag37.com> wrote:
13. Future differences: C# will support generics, don't think VB.NET will (soon anyways)


I believe it'll have it in the same release that C# does. From
http://msdn.microsoft.com/vstudio/pr...p.aspx#whidbey

<quote>
Finally, for the more advanced Visual Basic developer, language
enhancements include support for operator overloading, unsigned data
types, inline XML-based code documentation, and partial types. In
addition, developers using Visual Basic will have access to a type-
safe, high-performance, compile time-verified version of generics that
promote code reuse across a variety of data types.
</quote>


Wow, that's outstanding. Didn't realize they were adding so much of that -
I even read that article, but I must have skipped that paragraph. I might
be tempted to go back to VB.NET (that was my first exposure to .NET before I
discovered C#). I would miss {}'s and ;'s since my "real" background is
C++.

Wonder if they'll have the new iterators as well? I didn't see that
mentioned in the article.

mike
Nov 15 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

220 posts views Thread by Brandon J. Van Every | last post: by
699 posts views Thread by mike420 | last post: by
92 posts views Thread by Reed L. O'Brien | last post: by
137 posts views Thread by Philippe C. Martin | last post: by
12 posts views Thread by Dario | last post: by
47 posts views Thread by Neal | last post: by
86 posts views Thread by Michael Kalina | last post: by

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.