Switching to Visual C Sharp Programming From Visual Basic
In case you're figuring out how to program in Visual C# unexpectedly. However, you have a background in VB or VBA programming; this is the article for you! It sums up the fundamental concepts which you'll have to become accustomed to. How about we start with the touchy topic of declaring factors, and afterward proceed onward to case affectability.
Declaring Variables
In C#, you put the variable first, at that point its name, and afterward (alternatively) it's worth. For instance:
int I = 1;
This command would create a variable of type int, which is called I and which will hold the worth 1.
Case Sensitive Variables
Assume that you need to create a variable to hold a number, and you need to call it MyInteger. You type in the accompanying code:
int MyInteger = 0; lblExample.text = myinteger.tostring();
This will give you a mistake since MyInteger, and my integer isn't something very similar. In Visual C#, everything is case delicate. Fortunately gives you 52 letters to play with, not 26 - the awful news is that you'll need to compose everything carefully.
This watchword
In C#, utilize this to allude to the current object, as opposed to me. For instance: this.lblExample.text = 'hi';
Different changes
The above models represent various changes for Visual C# programming. These include:
You should end all commands with a semi-colon;
It will help if you put brackets after certain functions (for instance, ToString() above);
It would help if you utilized single quotes to enclose strings of text.
If Statements
In the event that you need to create an IF condition, you'll certainly need to figure out how to type in curly brackets on your console! Here's a basic condition:
in the event that (I-1) { lblExample.text = 'one'; } else { txtExample.text = 'not one'; }
From the above model, you can see that in Visual C# programs, the condition needs to go in round brackets and the explanations that follow the state need to go in enclosures. You can have an otherwise proclamation, followed by a progression of reasons to be executed in curly brackets.
Different Differences
There are numerous different differences when you're programming in Visual C#. For instance:
At the point when you're circling over collections, you'll utilize the for each watchword;
At the point when you're declaring exhibits or alluding to subscripts in clusters, you'll figure out how to utilize square brackets as opposed to cycle ones;
Calls to properties utilize distinctive language structure (even though the concepts are the equivalent)
I find that programming in Visual C# - once I become accustomed to it - is no more challenging than programming in VB, given that I recollect that everything is case-touchy!
See More: Visual Basic Programming Versus Visual C Sharp