- Support for optional parameters - very handy for some COM interoperability
- Support for late binding with
Option Strict
off - type safety at compile time goes out of the window, but legacy libraries which don't have strongly typed interfaces become easier to use. - Support for named indexers (aka properties with parameters).
- Various legacy VB functions (provided in the
Microsoft.VisualBasic
namespace, and can be used by other languages with a reference to theMicrosoft.VisualBasic.dll
). Many of these can be harmful to performance if used unwisely, however, and many people believe they should be avoided for the most part. Some methods here are apparently faster than the more idiomatic .NET equivalent, however. Readability should be considered: using VB functions probably makes the code easier for a VB-classic programmer to read, but harder for someone from a background in another .NET language to read. - Simpler (in expression - perhaps more complicated in understanding) event handling, where a method can declare that it handles an event, rather than the handler having to be set up in code.
- The ability to implement interfaces with methods of different names. (Arguably this makes it harder to find the implementation of an interface, however.)
Catch ... When ...
clauses, which allow exceptions to be filtered based on runtime expressions rather than just by type.- The VB.NET part of Visual Studio .NET compiles your code in the background. While this is considered an advantage for small projects, people creating very large projects have found that the IDE slows down considerably as the project gets larger. (Note: This may only affect VS.NET 2002. I haven't tested it yet with VS.NET 2003 or VS2005 beta 2.)
C# Advantages
- XML documentation generated from source code comments. (Available in VB.NET with Visual Studio 2005.)
- Operator overloading. (Available in VB.NET with Visual Studio 2005.)
- Language support for unsigned types. You can use them from VB.NET, but they aren't in the language itself. (Available in VB.NET with Visual Studio 2005.)
- The
using
statement, which makes unmanaged resource disposal simple. (Available in VB.NET with Visual Studio 2005.) - Volatile variables.
- Explicit interface implementation, where an interface which is already implemented in a base class can be reimplemented separately in a derived class. Arguably this makes the class harder to understand, in the same way that member hiding normally does.
- Unsafe code. This allows pointer arithmetic etc, and can improve performance in some situations. However, it is not to be used lightly, as a lot of the normal safety of C# is lost (as the name implies). Note that unsafe code is still managed code, i.e. it is compiled to IL, JITted, and run within the CLR.
0 comments:
Post a Comment