Is there a way we can run individual .cs files in Visual Studio Code.
I have followed this link and runs fine but then I added Program2.cs and try to run using "dotnet run Program2.cs" but it failed for obvious reasons saying
link
Program2.cs(7,21): error CS0111: Type 'Program' already defines a member called 'Main' with the same parameter types [csharp.csproj]"
Is there a way to run individual .cs files. Or any way I can run individual .cs files that outputs to terminal/command prompt or console.
dotnet command is just for .NET Core and you must do dotnet new console
command to generate a project to run it
if you are using .NET Framework and having the environment variables correctly set on your system, you can use csc Program.cs
command to individually compile a class file to an executable. But this way is highly deprecated for any further learning or development
For this i've always used this c# scripting engine : http://csscript.net,
very easy to implement and works very well and you can reference local dlls, Nuget packages or GAC assemblies.
It also has a Visual studio code plugin, so you can run with F5, debug ...
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