C# first program in visual studio code

Install the following 

  • Install .net 8 sdk. I have installed .net 8. It depends when you are watching this blog. You can update the latest sdk accordingly. You can install from below link.
  • After installation, type dotnet — version to confirm the version
  • Extensions to install
    • C#
    • C# Dev Kit
    • IntelliCode for C# Dev Kit
    • terminal-command-keys
      • This is for creating shortcut in keybinding.json which I have discussed below
    • Code Runner -(optional)
				
					anuragnayak@Anurags-MacBook-Pro C# % dotnet --version
8.0.303
				
			

Modify the keybinding.json for shortcut

  • Navigate to Keyboard shortcuts. Click on json settings.
  • terminal-command-keys extension to be installed as earlier pointed ☝️ 
  • Update the values as per below
  • As I have tried in mac, so the commands are placed as cmd. You can make your convinient shortcut key.
				
					// Place your key bindings in this file to override the defaults
[
    {
    "key": "cmd+3",
    "command":"terminalCommandKeys.run",
    "args":{
        "cmd": "dotnet run"
     }
    },
    {
    "key": "cmd+2",
    "command":"terminalCommandKeys.run",
    "args":{
        "cmd": "dotnet build"
     }
    },
    {
    "key": "cmd+1",
    "command":"terminalCommandKeys.run",
    "args":{
        "cmd": "dotnet clean"
     }
    },
]
				
			
				
					// See https://aka.ms/new-console-template for more information
Console.WriteLine("Hello, World!");
System.Console.WriteLine("anurag");

				
			
  • You can use below commands
    • dotnet clean
    • dotnet build
    • dotner run
  • Or you can use the shortcuts which I have created in keybinding.json

 

Leave a Comment