Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C#'s edge over VB [closed]

Tags:

c#

.net

vb.net

What in C#.NET makes it more suitable for some projects than VB.NET?

Performance?, Capabilities?, Libraries/Components?, Reputation?, Reliability? Maintainability?, Ease?


Basically anything C# can do, that is impossible using VB, or vice versa. Things you just have to consider when choosing C#/VB for a project.

like image 457
Robin Rodricks Avatar asked Dec 19 '08 07:12

Robin Rodricks


People also ask

What C is used for?

C programming language is a machine-independent programming language that is mainly used to create many types of applications and operating systems such as Windows, and other complicated programs such as the Oracle database, Git, Python interpreter, and games and is considered a programming foundation in the process of ...

Is C language easy?

C is a general-purpose language that most programmers learn before moving on to more complex languages. From Unix and Windows to Tic Tac Toe and Photoshop, several of the most commonly used applications today have been built on C. It is easy to learn because: A simple syntax with only 32 keywords.

What is C in C language?

What is C? C is a general-purpose programming language created by Dennis Ritchie at the Bell Laboratories in 1972. It is a very popular language, despite being old. C is strongly associated with UNIX, as it was developed to write the UNIX operating system.

What is the full name of C?

In the real sense it has no meaning or full form. It was developed by Dennis Ritchie and Ken Thompson at AT&T bell Lab. First, they used to call it as B language then later they made some improvement into it and renamed it as C and its superscript as C++ which was invented by Dr.


1 Answers

C# and VB are basically the same however there are some minor differences. Aside from the obvious grammar differences you have the following differences:

  1. C# can call unsafe code
  2. VB has optional parameters (Coming in C#4.0)
  3. VB is easier to use when making late bound calls (Coming in C# 4.0) This and number make 2 make using VB to do office automation much cleaner.
  4. VB has a bunch of "helper" functions and class like the My namespace; however, all of this are accessible to C#
  5. VB is case insensitive

C#'s syntax follow a similar grammar to c and java, which make it a much more comfortable transition from those languages, where as VB can be more comfortable to VB users. As far performance, and libraries or components they are nearly identical.

As for which one to choose, unless you have a need to do unsafe operations, then choose the language which is most natural to you. After years of being a VB developer I loved not having to write If yadada then.....End If if (yadaya){....} saves my carpal tunnel a few extra keystrokes (Which can then be used on answering SO questions)

Edit

Just learned one more difference btw C# and VB is that VB supports filtered exceptions so you could something like this pseudo:

try
{
   //do something that fails
}
catch(Exception ex when ArgumentException, 
      ArgumentNullException, FormatException)
{
  //Only handle these three types
}

This should not be confused with the ability to do:

try
{ 
    //something that fails
}
catch(ArgumentException)
{ 
    //Log Error
}
catch(ArgumentNullException)
{
    //Log Error
}

In this case you are going to handle the exceptions differently in the VB world you could define one piece of code to handle multiple types of Exceptions.

Edit

Some more differences.

  1. VB's Is operator compares two objects to determine if they are the same it compiles to the CEQ IL instruction where as C# compiles to isinst IL. So the following are equivalent statements

c# if (foo is FooObject){}

vb If TypeOf foo is FooObject then

  1. Also as mentioned in the comments and I wish I could see them to give you credit but C# doesn't have a like parameter. You need to use the RegEx class.
like image 110
JoshBerke Avatar answered Oct 16 '22 11:10

JoshBerke