C# – How to write code ?

Write Code

First, type the letter “C”. You’ll see a popup menu. This popup menu is called the IntelliSense menu. It tries to guess what you want and allows you to quickly add the item from the list. But it should look like this after you have typed a capital letter “C”:

class-csharp-tutorials
class-csharp-tutorials

The icon to the left of the word Console on the list above means that it is a Class. But press the Enter key on your keyboard. The word will be added to your code:

Now type a full stop (period) immediately after the word Console. The IntelliSense menu appears again

csharp-tutorials
csharp-tutorials

Now type a left round bracket. As soon as you type the round bracket, you’ll see this:

csharp-tutorials
csharp-tutorials

WriteLine is another Method (A Method is just some code that does a particular job). But the yellow box is telling you that there are 19 different versions of this Method. You could click the small arrows to move up and down the list. Instead, type the following
<h2″>”Welcome to kaushalstreet”;

Now type a right round bracket:

Notice the red wiggly line at the end. This is the coding environment’s way of telling you that you’ve missed something out.

The thing we’ve missed out is a semicolon. All complete lines of code in C# must end with a semicolon. Miss one out and you’ll get error messages. Type the semicolon at the end and the red wiggly line will go away. Your code should now look like this:

csharp-tutorials
csharp-tutorials

Note all the different colors. Visual C# color-codes the different parts of your code. The reddish color between double quotes means that you want text; the green color means it’s a Class; blue words are ones that C# reserves for itself.

Note: If you want, you can change these colors. From the menu bar at the top, click Tools > Options. Under Environment, click Fonts and Colors.