Products Purchase Publishing Articles Support Company Contact |
Products > Books > .NET > Visual Basic .NET or C# > Updates |
|||||||
Moving to VB .NET: Strategies, Concepts and Code Introduction Table of Contents Sample Chapter Sample Code Updates Visual Basic .NET or C#: Which to Choose Updates Regular Expressions with .NET Updates Obfuscating .NET: Protecting your code from prying eyes Updates Tracing and Logging in .NET Telling Time with .NET Hijacking .NET (series) Exploring .NET (series)
|
Note: This page describes a product or book that, while still relevant to .NET programmers, is based on an earlier version of the .NET framework. The page is available for archival purposes and as a courtesy to those who have linked to it, but is no longer being updated or maintained.
Visual Basic .NET or C#: Which to Choose.....
|
|
The following corrections apply only to the first edition of the book: Visual Basic.NET or C#...Which to Choose
The following additional language differences are included in the second edition.
?:, ++, -- Operators
C# includes ?: (conditional assignment), ++ (increment) and -- (decrement) operators.
Verdict: I'll give this one to C#, but given that these operators increase brevity at the cost of readability, you can make a case that their lack in VB.NET should really represent a win for VB.NET.
Redim Preserve
Visual Basic.NET allows you to redimension an array while preserving the current contents using the Redim Preserve statement.
Verdict: A definite win for VB.NET, but a minor one given that the .NET framework has a variety of array and collection types that support dynamic sizing almost as easily.
With Statement
The VB.NET With statement can be used to create a block in which it is possible to directly access methods or objects nested in an object hierarchy. This can result in more easily readable code.
Verdict: Though convenient, and frequently used by VB.NET programmers, this feature does not represent a significant advantage.
Parameterized Properties
Both C# and VB.NET allow you to create default class properties that take parameters. These are called indexers in C# (which take only a single index parameter). VB.NET also allows you to create non-default properties that take one or more parameters - a feature that C# lacks.
Verdict: A minor win for VB.NET. Most applications of parameterized properties are better handled by methods anyway.
References to unmanaged code on pages 26-27 should actually be unsafe code . C# uses managed code, but has the ability to access unmanaged memory using unsafe code.
New Appendix A
The previous appendix A has been labeled appendix B, and an appendix based on reader feedback has been added.
Reader Feedback
A number of readers took me up on my invitation and sent me email commenting on various parts of this article. Some of their comments have been incorporated into the text for the second edition. Others either have no real bearing on the content or conclusions. And there are others that I left out because I simply disagree with them. Here is a selection from those comments that were not incorporated into the current edition of the ebook.
VB.NET sounds a lot better than C# when pronouncing them out loud. Face it, C# as a name, stinks.
I must admit, I rather like the name C#. At least it sounds more elegant than C++.
I was surprised not to see any mention of the late-bound capabilities in VB vs. having to use reflection in C#.
That's because VB.NET's ability to automatically perform late bound calls only works if you turn off Option Strict. I consider Option Strict to be an important new feature in VB.NET that should always be enabled. With Option Strict on, VB.NET handles late binding through reflection just like C#.
I am concerned that the quality and quantity of learning material will be higher for C#.
This is certainly true today.
Publishers naturally rushed to fill the inevitable void caused by the appearance of a new language. I have no doubt there will be many VB.NET books. I'm not quite conceited enough to claim that my Moving to VB.NET book has addressed the quality issue single-handed, but I am proud of how it turned out and think it will help.
This article may lead one to believe (by its title) that C# and Visual Basic.NET are the only ways to use .NET.
Last I heard there were some 20 .NET languages under development. This book refers to VB.NET or C# because these are the languages that are being considered by large numbers of today's Visual Basic programmers.
VB.NET does not support jagged arrays (arrays of other arrays whose lengths aren't equal)
Yes it does - the feature was added for beta 2.