Saturday 9 September 2017

Compiling and running first c# program using default compiler that comes with Windows Operating System



windows sdk comes with a default c# compiler.
In order to use the default c# compiler that comes with windows operating system, follow the steps shown below:
1. include the below url in path environment variable
C:\Windows\Microsoft.NET\Framework64\v4.0.30319

2. Open notepad and write your first c# program and save the file with the same name as class name with .cs extension

For ex: if you copy and paste the below code in notepad
using System;
namespace DeclaringConstants
{
    class Program
    {
        static void Main(string[] args)
        {
            const double pi = 3.14159;  
           
            // constant declaration
            float r;
            Console.WriteLine("Enter Radius: ");
            r = (float)Convert.ToDouble(Console.ReadLine());
            double areaCircle = pi * r * r;
            Console.WriteLine("Radius: {0}, Area: {1}", r, areaCircle);
            Console.ReadLine();
        }
    }
}

Save the file as Program.cs

3. Open command prompt and type
>>csc Program.cs

4. If incase u get no error, type
>>Program

5. Output will be as follows

No comments:

Post a Comment