c# template code vscode code example

Example 1: how to make a C# application visual studio code

mkdir MyApp; cd MyApp;
dotnet new console

Example 2: vs code run and build task c#

"tasks": [
        {
            "label": "build",
            "command": "dotnet",
            "type": "shell",
            "args": [
                "build",
                "/property:GenerateFullPaths=true",
                "/consoleloggerparameters:NoSummary"
            ],
            "group": "build",
            "presentation": {
                "reveal": "silent",
                "echo": false
            },
            "problemMatcher": "$msCompile"
        },
        {
            "label": "run",
            "dependsOn": ["build"],
            "command": "dotnet",
            "args": [
                "run"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            },
            "presentation": {
                "reveal": "always",
                "echo": false
            }
        }
    ]

Example 3: vscode user snippets

"For Loop": {
    "prefix": "for",
    "body": [
        "for (var ${index} = 0; ${index} < ${array}.length; ${index}++) {",
        "\tvar ${element} = ${array}[${index}];",
        "\t$0",
        "}"
    ],
    "description": "For Loop"
},

Tags:

Misc Example