Sunday, January 25, 2015

the .NET babies: Visual basic & C#

While you have a few years of experience for one of the language ( VB or C#), you might found some time is needed for yourself when you want to code another language. It is easy to read and understand them but when it comes to write, you might become not as fast as when you code using the other language. This is because of the syntax! (It makes me felt that this is just like some people can understand Cantonese but cannot speak in Cantonese. hehe..) 

First, C# is case sensitive while VB is case insensitive.
So,
you can do this to C# ==> Var i = 1; Var I = 10;
But,
you cannot do this to VB ==> Dim i as Integer = 1  Dim I as Integer = 10
the compiler will definitely complain about double declaration.



I sometimes like to start using "Public" in C#. Yes, this is not correct in C#! C# wants "public"...
argh... :)

these are some of the "daily used" operators for both .

VB   ***   C#
simple operator:
AND   ***   &
OR   ***   |

short-circuit :
ANDALSO   ***   &&
ORELSE   ***   ||

not null   ***   != null
<>   ***   !=
=   ***   ==

if (language == "C#")
{
}

If language = "VB" Then
End If

As more people like to link .NET and OOP to C#, recently, C# seems to be more popular. Of cause both C# and VB are the language that you can code using the .NET platform, in OOP way. VB on the other hand is very easy to use and learn. Compare to C#, VB contain more "wording", some developer has different preference about this.

If a developer doesn't like to craft their code, even with good technical knowledge and OOP conceptual knowledge, their code can turn to food! Which are sometimes known as..Spaghetti code.

No comments:

Post a Comment