This is my first time using Visual Studio Code and I am trying to run a simple code on it but it is giving me an error that says:
'scriptcs' is not recognized as an internal or external command, operable program or batch file.
I have this as code:
using System;
struct Employee{
public int Id { get; set; }
public string FullName { get; set; }
}
public class MyClass{
public static void Main(){
Employee obj= new Employee();
obj.FullName = "Hello World";
Console.WriteLine(obj.FullName);
}
}
I have tried installing the Scriptcs Runner, but still the same issue. Can anybody suggest something else?
Edit:
After many of your suggestions I tried the following:
- Created an entire new folder without spaces and named the files the same way.
- Re-installed the scriptcs Runner extension from VS Code Extension manager.
- Doubled checked my code. It is running on online c# compiler, but not in VS Code.
Problem is still the same. Getting the above error.
Open the Extensions and install the C# extension: Name: C#, ,Id: ms-vscode.csharp ,Description: C# for Visual Studio Code (powered by OmniSharp). ,Publisher: Microsoft ,VS Marketplace Link: https://marketplace.visualstudio.com/items?itemName=ms-vscode.csharp
Go to console into a folder of your choice and create a new console project by typing
dotnet new console -o TestConsoleApp
This will create a project file TestConsoleApp.csprojStart VS Code by typing
Code .
In VS Code goto Terminal and execute
dotnet run --project TestConsoleApp
to run your application. Alternatively you can start Debugging (F5)This should provide you a good start where you then can use your code.
If you just want to use code snippets, you should try what Athanasios Kataras answered but with that I have no experience.
There is a also video introduction for this available at https://channel9.msdn.com/Blogs/dotnet/Get-started-VSCode-Csharp-NET-Core-Windows