I am very new to C#. I have just run C# 'Hello World' program using Visual Studio.
Can I run or compile a C# program without using Visual Studio?
If it is possible, then which compiler should I use?
Thanks
Opening a file is performed using the fopen() function defined in the stdio. h header file. The syntax for opening a file in standard I/O is: ptr = fopen("fileopen","mode");
C is a mid-level language and it needs a compiler to convert it into an executable code so that the program can be run on our machine.
If you have .NET v4 installed (so if you have a newer windows or if you apply the windows updates)
C:\Windows\Microsoft.NET\Framework\v4.0.30319\csc.exe somefile.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 ...
I use a batch script to compile and run C#:
C:\Windows\Microsoft.NET\Framework\v4.0.30319\csc /out:%1 %2 @echo off if errorlevel 1 ( pause exit ) start %1 %1
I call it like this:
C:\bin\csc.bat "C:\code\MyProgram.exe" "C:\code\MyProgram.cs"
I also have a shortcut in Notepad++, which you can define by going to Run > Run...:
C:\bin\csc.bat "$(CURRENT_DIRECTORY)\$(NAME_PART).exe" "$(FULL_CURRENT_PATH)"
I assigned this shortcut to my F5 key for maximum laziness.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With