You must Sign In to post a response.
  • Category: Windows 10

    How to write and compile c# program using notepad and .microsoft.net framework

    How We can write c# application using notepad and csc compiler from .net framework
    without using visual Studio.
  • #769046
    Hi,

    You can do it with the command prompt. We can just create the program file in the notepad or notepad++ and we can run the code using prompt window.

    Kindly check the below link for complete details.


    http://www.tomasvera.com/programming/compiling-a-c-project-using-command-line-tools-tutorial/

    Thanks,
    Mani

  • #769047
    Hai Muhammad Aslam Khan Waqa,
    If you want to write a C# program in notepad and then you want to compile it and run it successfully, you need to follow the below steps:
    1. Open a Notepad and write the program very carefully because C# is case sensitive and in notepad its difficult to maintains. So you need to be very careful while writing the program in Notepad.
    2. Once the program is written in notepad, you need to save it with .cs extension. Here .cs represents C Sharp and then only the visual studio can recognize this file by its C Sharp compiler.
    3. Now open the Visual Studio --> New Project --> Console application for C# template because your file can be understand by C Sharp compiler.
    4. Write the command to compile the program as below:

    C:>CSharp <path of the file>

    Also you can change the directory to the file where you have saved your file and then just use the command:

    D:>CSharp

    It will compile your program.
    5. To run the application, press F5
    6. The output will be on the console application result window.
    Hope it will be helpful to you.

    Regards,
    Pawan Awasthi(DNS MVM)
    +91 8123489140 (whatsApp), +60 14365 1476(Malaysia)
    pawansoftit@gmail.com

  • #769050
    If you have the .NET v4 installed (so if you have a newer windows or if you apply the windows updates) then you can compile your code without visual studio, your code can be either in notepad or in any editor
    following compiler exe's can be useful for it

    C:\Windows\Microsoft.NET\Framework\v4.0.30319\csc.exe nomefile.cs

    or
    C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe nomefile.sln

    or
    C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe nomefile.csproj


    It's highly probable that if you have .NET installed, the %FrameworkDir% variable is set, so:
    %FrameworkDir%\v4.0.30319\csc.exe ...

    %FrameworkDir%\v4.0.30319\msbuild.exe ...

    Thanks
    Koolprasd2003
    Editor, DotNetSpider MVM
    Microsoft MVP 2014 [ASP.NET/IIS]

  • #769056
    Hi,

    If you want to write the c# program in notepad then write the c# program with proper syntax then save the file with .cs extension.

    Secondly open the Visual Studio Command Prompt then set the path where the notepad(.cs extension) file is saved, and then compile your program using csc command

    Ex:

    YourFilePath>csc filename.cs


    Refer below link to know more about the same

    http://www.completecsharptutorial.com/basic/run-csharp-code/

    Hope this helps you...

    --------------------------------------------------------------------------------
    Give respect to your work, Instead of trying to impress your boss.

    N@veen
    Blog : http://naveens-dotnet.blogspot.in/


Sign In to post your comments