Part-1 C# Syntax For VB.net Developer
Part-1 C# Syntax For VB.net Developer
Started
working on C# for a change. Found it to be more interesting and more challenging
than conventional Basics Langauge. To get break from routine work i started
developing sample application on c#. I am enjoy this more and more. Felt some
of the programming experience has to be shared.
While developing
found there some of the syntax changed and way they are defined are also
changed.
I have started series
of C# Syntax for VB.net Developers which may help you people too.
To Concatenate String + sign has to be used
VB.net uses & it has been replaced with + Sign in C#
All Variable define must have default value
string strSQL ="";
int32 intNumber =0;
Comment in C#
Single Line Comment //
Muti Line Comment /* */
Define Subroutines
private void DoSomething
{
}
Define Function
ex. private boolean ValidateDate()
{
return false;
}
Exit sub in C# : return
ex. private void DoSomeThing
{
return;
}
private boolean ValidateDate()
{
return false;
}
Function to always end with ( ) other wise it will take it as Property
ex. private boolean ValidateDate()
{
return false;
}
Defining Object for Class
StringBuilder strSQL = new StringBuilder();
Note :- This is how Constructors are to be used
All Class defination will end with ( )
Any Method Called for Control and Class Must end with ( )
ex. TextBox.Focus();
Textbox.Text.ToString();
Note :- All method must end ( )
Regions
#region "Region name"
private void DoSomething
{
}
private void PerfomSomething
{
}
#endregion
Nothing keyword is not support in C#
Nothing is Replaced with null
if (obj != null)
{
// perform the action
}
AndAlso and OrElse
AndAlso is replaced with &&
ElseOr is replaced with ||
Not Equal Or <> is C#
<> is replaced with !=
Equal To OR =
= is replaced with ==
Twice sign equal to has to be used for comparison of value
If Condition
if (X==1)
{
// perform Task
}
else
{
// perform Task
}
Event for Controls
There is not Handle Keyword in events for Control
ex. Check this Out Button Click Event, No Handle key Word for Map event and Method as we have it in VB.net
private void btnExit_Click(object sender, EventArgs e)
{
this.Close();
}
Instead Mapping is done in Design time Property Window for Control
Want to create Control Array for events
Add same method to both the Controls in property window {events option}
Format () function
In C# Format Function is moved under
String.Format()
To get a change start learning new technology, It has many advantage. So start now
Thanks SK... Keep up the good work....
ReplyDeleteThanks for your support, This keeps me running and take up new challenge. Working of Asp.net Syntax help too and Android development.
Delete