VB.NET

What Is Visual Basic .NET ?

 Visual Basic .NET is an OOPs language designed by Microsoft. With the word “Basic” being in the name of the language, you can already see that this is a language for beginners. Visual basic syntax is easy and you will not find yourself writing hundreds of lines of code as there are many shortcuts that make coding so much easier in this language.


If you have had any experience in computer programming, you should understand what a syntax is and the purpose of it. If not, let’s take a look at the VB.NET syntax. The purpose of typing code is to instruct the application what to do. If you wanted to tell your application to show a Message Box telling you that Hello World is interesting, this would be the code you would use:

MessageBox.Show("Hello World")


Difference between c# and VB.Net.
Visual Basic .NET and Visual C# .NET, both are first-class programming languages that are based on the Microsoft .NET Framework, and they are equally powerful. Visual Basic .NET is a true object-oriented programming language that includes new and improved features such as inheritance, polymorphism, interfaces, and overloading. Both Visual Basic .NET and Visual C# .NET use the common language runtime. There are almost no performance issues between Visual Basic .NET and Visual C# .NET. Visual C# .NET may have a few more "power" features such as handling unmanaged code, and Visual Basic .NET may be skewed a little toward ease of use by providing features such as late binding. 

Here are some key difference in C# and VB.NET other than syntax difference.

1:C# is case sensitive but VB.net is not case sensitive. 

2:In C#, using keyword is used to release unmanaged resources which is not available in VB.NET.
3:Optional parameter is supported in VB.NET but C#  not supported that.
4:C# is  Object Oriented Programming Language   and consist most important features are Polymorphism ,Encapsulation ,Abstraction etc .  Encapsulation is data hiding concept by which you can provide a new implementation for the base class member without overriding the member . You can hide a base class member in the derived class by using "new" keyword . The method signature ,access level and return type of the hidden member has to be same as the base class member .Comparing the two:-
I) The access level, signature and the return type can only be changed when you are shadowing with VB.NET. Hiding and overriding demands these parameters as same.

II) The difference lies when you call the derived class object with a base class variable. In class of overriding although you assign a derived class object to base class variable it will call the derived class function. In case of shadowing or hiding the base class function will be called.

In VB.Net you can provide a new implementation for the base class member without overriding the member. You can shadow a base class member in the derived class by using the keyword “Shadows”. The method signature, access level and return type of the shadowed member can be completely different than the base class member.

Keyword Differences


Purpose
VB.NET
C#
Declare a variable
PrivatePublicFriend,ProtectedStatic1SharedDim
declarators (keywords include user-defined types and built-in types)
Declare a named constant
Const
const
Create a new object
NewCreateObject()
new
Function/method does not return a value
Sub
void
Overload a function or method (Visual Basic: overload a procedure or method)
Overloads
(No language keyword required for this purpose)
Refer to the current object
Me
this
Make a nonvirtual call to a virtual method of the current object
MyClass
n/a
Retrieve character from a string
GetChar Function
[]
Declare a compound data type (Visual Basic: Structure)
Structure <members> End Structure
structclassinterface
Initialize an object (constructors)
Sub New()
Constructors, or system default type constructors
Terminate an object directly
n/a
n/a
Method called by the system just before garbage collection reclaims an object7
Finalize
destructor
Initialize a variable where it is declared
Take the address of a function
AddressOf (For class members, this operator returns a reference to a function in the form of a delegate instance)
delegate
Declare that an object can be modified asynchronously
n/a
volatile
Force explicit declaration of variables
Option Explicit
n/a. (All variables must be declared prior to use)
Test for an object variable that does not refer to an object
obj = Nothing
obj == null
Value of an object variable that does not refer to an object
Nothing
null
Test for a database null expression
IsDbNull
n/a
Test whether a Variant variable has been initialized
n/a
n/a
Define a default property
Default
by using indexers
Refer to a base class
MyBase
base
Declare an interface
Interface
interface
Specify an interface to be implemented
Implements (statement)
class C1 : I1
Declare a class
Class <implementation>
class
Specify that a class can only be inherited. An instance of the class cannot be created.
MustInherit
abstract
Specify that a class cannot be inherited
NotInheritable
sealed
Declare an enumerated type
Enum <members> End Enum
enum
Declare a class constant
Const
const (Applied to a field declaration)
Derive a class from a base class
Inherits C2
class C1 : C2
Override a method
Overrides
override
Declare a method that must be implemented in a deriving class
MustOverride
abstract
Declare a method that can't be overridden
NotOverridable (Methods are notoverridable by default.)
sealed
Declare a virtual method, property (Visual Basic), or property accessor (C#, C++)
Overridable
virtual
Hide a base class member in a derived class
Shadowing
n/a
Declare a typesafe reference to a class method
Delegate
delegate
Specify that a variable can contain an object whose events you wish to handle
WithEvents
(Write code - no specific keyword)
Specify the events for which an event procedure will be called
Handles (Event procedures can still be associated with a WithEventsvariable by naming pattern.)
n/a
Evaluate an object expression once, in order to access multiple members
n/a
Structured exception handling
trycatchfinally, throw
Decision structure (selection)
Select Case ...CaseCase ElseEnd Select
switchcasedefaultgotobreak
Decision structure (if ... then)
If ... ThenElseIf ... Then,ElseEnd If
ifelse
Loop structure (conditional)
While, Do [WhileUntil] ...,Loop [While, Until]
dowhilecontinue
Loop structure (iteration)
For ...[Exit For], Next
For Each ..., [Exit For,] Next
forforeach
Declare an array
Initialize an array
Reallocate array
redim
n/a
Visible outside the project or assembly
Public
public
Invisible outside the assembly (C#/Visual Basic) or within the package (Visual J#, JScript)
Friend
internal
Visible only within the project (for nested classes, within the enclosing class)
Private
private
Accessible outside class and project or module
Public
public
Accessible outside the class, but within the project
Friend
internal
Only accessible within class or module
Private
private
Only accessible to current and derived classes
Protected
protected
Preserve procedure's local variables
Static
n/a
Shared by all instances of a class
Shared
static
Comment code
'
Rem
//, /* */ for multi-line comments
/// for XML comments
Case-sensitive?
No
Yes
Call Windows API
Declare <API>
use Platform Invoke
Declare and raise an event
EventRaiseEvent
event
Threading primitives
SyncLock
lock
Go to
Goto
goto




Data types Differences

Purpose/Size
VB.NET
C#
Decimal
Decimal
decimal
Date
Date
DateTime
(varies)
String
string
1 byte
Byte
byte
2 bytes
Boolean
bool
2 bytes
ShortChar (Unicode character)
shortchar (Unicode character)
4 bytes
Integer
int
8 bytes
Long
long
4 bytes
Single
float
8 bytes
Double
double

Operators Differences

Purpose
VB.NET
C#
Integer division
\
/
Modulus (division returning only the remainder)
Mod
%
Exponentiation
^
n/a
Integer division Assignment
\=
/=
Concatenate
&= NEW
+=
Modulus
n/a
%=
Bitwise-AND
n/a
&=
Bitwise-exclusive-OR
n/a
^=
Bitwise-inclusive-OR
n/a
|=
Equal
=
==
Not equal
<>
!=
Compare two object reference variables
Is
==
Compare object reference type
TypeOf x Is Class1
x is Class1
Concatenate strings
&
+
Shortcircuited Boolean AND
AndAlso
&&
Shortcircuited Boolean OR
OrElse
||
Scope resolution
.
. and base
Array element
()
[ ]
Type cast
CintCDbl, ..., CType
(type)
Postfix increment
n/a
++
Postfix decrement
n/a
--
Indirection
n/a
* (unsafe mode only)
Address of
AddressOf
& (unsafe mode only; also see fixed)
Logical-NOT
Not
!
One's complement
Not
~
Prefix increment
n/a
++
Prefix decrement
n/a
--
Size of type
n/a
sizeof
Bitwise-AND
And
&
Bitwise-exclusive-OR
Xor
^
Bitwise-inclusive-OR
Or
|
Logical-AND
And
&&
Logical-OR
Or
||
Conditional
If Function ()
?:
Pointer to member
n/a
. (Unsafe mode only)

I think it will help you to understand about VB.Net and C#

Comments

  1. very informative blog and useful article thank you for sharing with us , keep posting learn

    more about Dot net
    Dot NET Online Course Hyderabad

    ReplyDelete
  2. I am happy to know. thank you so much for giving us a chance to have this opportunity.. This is the exact information I am been searching for, Thanks for sharing the required infos with the clear update and required points.


    Dot Net Training in Chennai | Dot Net Training in anna nagar | Dot Net Training in omr | Dot Net Training in porur | Dot Net Training in tambaram | Dot Net Training in velachery

    ReplyDelete

Post a Comment

Popular posts from this blog

Convert HtmlToPDF in ASP.net & iTextshrap

Create Pivot Table In C#

How to Display Page Wise Total Amount & Grand Total Amount in Last page SSRS & RDLC Report