FAQ: Setting up a C# Environment - VS Code Personalization and Snippets

This community-built FAQ covers the “VS Code Personalization and Snippets” exercise from the lesson “Setting up a C# Environment”.

Paths and Courses
This exercise can be found in the following Codecademy content:

Build Web Apps with ASP.NET

Learn C#

FAQs on the exercise VS Code Personalization and Snippets

There are currently no frequently asked questions associated with this exercise – that’s where you come in! You can contribute to this section by offering your own questions, answers, or clarifications on this exercise. Ask or answer a question by clicking reply (reply) below.

If you’ve had an “aha” moment about the concepts, formatting, syntax, or anything else with this exercise, consider sharing those insights! Teaching others and answering their questions is one of the best ways to learn and stay sharp.

Join the Discussion. Help a fellow learner on their journey.

Ask or answer a question about this exercise by clicking reply (reply) below!
You can also find further discussion and get answers to your questions over in #get-help.

Agree with a comment or answer? Like (like) to up-vote the contribution!

Need broader help or resources? Head to #get-help and Tips and Resources. If you are wanting feedback or inspiration for a project, check out Projects.

Looking for motivation to keep learning? Join our wider discussions in Community

Learn more about how to use this guide.

Found a bug? Report it online, or post in Bug Reporting

Have a question about your account or billing? Reach out to our customer support team!

None of the above? Find out where to ask other questions here!

the csharp.json snippet within my vs code is not the same as what’s in the video for snippets. I tried adding what the video has and got loads of errors. Not sure if this is normal, or if it’s just something on my end. This is what I get when opening the csharp.json snippet in my vs code.

{
// Place your snippets for csharp here. Each snippet is defined under a snippet name and has a prefix, body and
// description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. Placeholders with the
// same ids are connected.
// Example:
// “Print to console”: {
// “prefix”: “log”,
// “body”: [
// “console.log(‘$1’);”,
// “$2”
// ],
// “description”: “Log output to console”
// }
}

So I did a complete reinstall of VS Code and it didn’t really help anything. I tried adding the example code from the video:

“Main method”: {
“prefix”: “main”,
“body”: [
“using System;”,
“”,
“class Program”,
“{”,
" static void Main(string args",
" {“,
" ${1:// Your code here}”,
" Console.WriteLine("Hello, World!");“,
" }”,
“}”
],
“description”: “Log output to console”
}

Found that, for some reason, indentations were causing issues starting with the “static void” section. replacing the indentations with just regular spaces seemed to work and not give issues or errors.

2 Likes

I’m in the same boat as you, was going to attempt to copy in the code but I was seeing errors due to indentation too. Not sure if you’ve found a work-around but hopefully an answer is provided soon

This is what I found that was wrong with mine when trying to copy the code in the video. Hope it helps.

{
// Place your snippets for csharp here. Each snippet is defined under a snippet name and has a prefix, body and
// description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. Placeholders with the
// same ids are connected.
// Example:
“Main method”: {
“prefix”: “main”,
“body”: [
“using System;”,
“”,
“class Program”,
“{”,
" static void Main(string args)“,
" {”,
" ${1:// Your code here}“,
" Console.WriteLine("Hello, World!");”,
" }",
“}”
],
“description”: “Log output to console”
}
}

^^^^^
This was the code that worked for me on this section with a pic of spacing, btw. Thought I could add it directly for easier help. :sweat_smile:

1 Like

You’re a legend, thanks this fixed it for me!

1 Like

Hey, no worries. Glad I could help. Lol.

1 Like

I am using Visual Studio IDE version 17.11.3.

40 seconds into Video 4 it calls for View → Command Palette. I don’t get a Command Palette option under View, nor does a search present one, so none of the subsequent instructions for opening settings.json work.

Searching for "Preferences: Open User Settings (JSON) does not turn up anything and does not open a file/tab settings.json.

Can someone help me open settings.json? A google search has led to instructions and videos that also don’t help. For example, Shift-Ctrl-P opens the search window and F1 reports “Help is not available for the current context.”

VS code (https://code.visualstudio.com) and Visual Studio IDE (https://visualstudio.microsoft.com) are not the same product.

“View —> Command Palette” works in VS Code.

The first video gives a brief comparison of the two.

The fifth video is about Visual Studio IDE.

good day to you guys am so new here trying to blend in. am totally fresher to the system, so anybody to help a wonderer here

After writing the csharp.json code and saving, I went to the Program.cs file, deleted its contents, and typed “mai” and tab. Nothing happened. The snippet was not inserted.

Do you see any errors in my code?

Hi!
So I’ve followed the steps in the setting up the enviroment part even if I skipped editing the font size and spaces.
For some reason the command palette refused to find csharp.json…
Any tips?

Regards

1 Like

I didn’t have a csharp.json file yet so I created a new global snippet and named it that. I copied over the code from the video and saved before trying the “main” snippet and this is what it gave me:
image
pls help i’m so confused

1 Like