Lesson 1.2

Where to write c sharp code?


This Chapter Covers

Objective

Where to write c# code?
Which sdk or tool is best for c# programming?
How to compile program written in Notepad Text Editor?

Let’s start

Welcome to your first official chapter of c# programming. Study slowly and carefully this chapter because it will be base of your entire next lesson. However, you may have your option to go with but it is strongly recommended you to choose prescribed method by this article. For example, you may choose notepad for writing visual c sharp coding but it is recommended to use Visual Studio SDK.

Yes, there are various text editors which allows you to write and debug C# code but Visual Studio SDK is the most popular editor which makes coding simple, structured and easy to understand. However, if you have not installed visual studio sdk you can also use Notepad text editor for writing code. In this lesson we will describe notepad and Visual Studio SDK and their compiling techniques.

Notepad Text Editor

Notepad is the default text editor which is automatically installed with windows OS. It is lightweight, easy to use, have short menu option and readable by maximum devices. Notepad Text Editor can also be used for writing C# coding and executing them.

How to compile program written in Notepad Text Editor?

Step 1: Open Notepad. Press Windows + R key simultaneously, Type Notepad in Run Command Editor and click OK.

Run Window

Step 2: Now write or copy paste following program in notepad.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace NotepadEditor
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Writing Program on NOTEPAD TEXT EDITOR");
            Console.ReadLine();
        }
    }
}
		  

Step 3: Save Notepad with the name of NotepadEditor.cs. You must select All Files (*.*) in File Types

Congratulations!!! You have successfully passed your half way. Now it's time to compile and run your program.

Compile and Execute Program

Step 1: Open Visual Studio Command Prompt. To open it go to following direction.

  1. Click on Start Menu
  2. Go to All Programs > Microsoft Visual Studio 2012 > Visual Studio Tools > Developer Command Prompt for VS2012
Start Menu

Step 2: Go to the location where your NotepadEditor.cs file is stored. We assume that you have stored your file in csharp folder in D drive. Type the following command and hit enter.

D:     Press Enter
cd csharp     Press Enter

Program Location

Step 3: Now you are in your CSHARP folder and this folder contains your cs program file.

Drive Location

Step 4: COMPILE your code

csc NotepadEditor.cs

If everything goes right then you see the following messages.

Compile Code

Step 6: Execute your PROGRAM. Only type your filename without extension and hit enter. You will see the following output on command prompt.

Output: Writing Program on NOTEPAD TEXT EDITOR

Execute Program

This is the method of writing and compiling program on notepad editor. You can write any other program and execute in the same way as described above. Next, we will see the Visual Studio SDK for writing same program.

Visual Studio SDK

Visual Studio SDK is the most powerful, easy, structured and intelligent development kit which made your programing easy, hassle free and error free. We have seen Notepad Editor and now it’s time to feel Visual Studio SDK. In the next chapter, you will learn how to use Visual Studio SDK for writting C# Code.

In this chapter you have learned about c# code editor and also learn how to compile program in visual studio command prompt written in Notepad. In the next chapter to last chapter we will use Visual Studio SDK for learning C sharp tutorial. In the next chapter you will get some programming examples and challenges. You must go through all the exercises.

BackNext