April 06, 2011

Compile and Execute C# (C sharp) code without Visual Studio and with .NET Framework

Hi everyone,

Today I have come across executing C# (C Sharp) code with out Visual Studio, but you must have .NET Framework installed on your computer.

Procedure:

  1. Install .NET Framework, if not installed.
  2. Set the path of the .NET Framework Edition in environment variables or by using SET PATH command.
  3. ex: C:\Windows\Microsoft.NET\Framework\v3.5
  4. Write the C# script, Save file with extension .cs
    ex: D:\csharp\trail.cs
    using System;

    public class Example
    {
        public static void Main()
        {
            Console.Write("\nIts Done\n");

            Console.ReadLine(); //Waits until user press Return
    (Enter) key
        }
    }
  5. Open command prompt, change the directory to specified folder(ex: D:\csharp\)
  6. Execute the following command
  7. cmd> csc trail.cs
  8. We will get trail.exe in the specified folder(ex: D:\csharp\), if it executed successfully
  9. Double click the trail.exe and see the output.
  10. We have successfully executed C#(C sharp) code without visual studio and with .NET Framework only
References:
http://blogs.oberon.ch/tamberg/2007-10-17/compiling-csharp-without-visual-studio.html

Please post your comments and feedback.

2 comments:

Anonymous said...

yeah but what with Windows Programminh in C# ?

Suresh Raju Pilli said...

windows programming with C# can also be done without Visual Studio. We are using Visual Studio to make our life easy while coding. Intellisence (Autofill), Compile, Execute and Debug is easy.

Featured Post

Java Introdcution

Please send your review and feedback to psrdotcom@gmail.com