C# Elementary3 Back to the streetsVisual Studio extension

A Shitload of Features

I turned back towards the resistance base when the guy suddenly shouted, "What tool do you use to write your code?"

"I use a keyboard to type, and..." but he interrupted me: "Are you kidding, man? I mean what IDE do you use?" He was laughing as if I had intentionally made a joke.

"What is an IDE?" I asked.

"IDE stands for Integrated Development Environment. It's a software tool where programmers write code. It looks like a very cool text editor but includes a shitload of features. You should definitely know and use one for C#. I'm guessing you don't?"

"No, I was writing code wherever people asked me to... I don't know how it all works." I replied.
"Yo, man! You don't need to know HOW an IDE works. Just learn how to use it, kid!"

"Okay then, what IDE do you use?" I asked.
"I have a Visual Studio 2022 tutorial that I downloaded from the darknet network a few years ago," he replied, "It works both for C and C#. Try it! You are smart, kid, you can find it! I need to go now, see ya in hell!"

"What? Hell? Why in hell? Was that a joke or a threat? Wait!" I tried to get the man's attention but he had bolted off and was already around a corner. There was only me and a virtual screen with the Visual Studio 2022 tutorial.

keep calm and learn with Codeasy

Visual Studio 2022 Community Edition

Visual Studio is a full-featured integrated development environment (IDE) for Android, iOS, Windows, web, and cloud. We are going to use it for C# development under Windows. Visual Studio provides various tools to make development more comfortable, enjoyable, and efficient. Visual Studio came in second in a list of the most popular developer environments. The only IDE ranked higher was... also Visual Studio (a different version)!

Before we dive into the magic behind IDEs, let's go over the main advantages of using Visual Studio:

  1. Setup is quick and easy. As soon as you install Visual Studio, you are ready to compile and run C# code with no additional installations or tweaking required.
  2. Visual Studio provides descriptive error messages with the line number at which the error occurred. Double-clicking the error message will put a cursor in the place where the error occurred.
  3. Trying your solutions in Visual Studio is extremely fast and you get instant results.
  4. The Visual Studio code editor's IntelliSense feature provides small hints to help you write code. For example, after typing Console.Wr in the code editor, you'll see a list of suggestions that you can scroll through by pressing the down arrow and choose by pressing Enter.

    C# intellisense

  5. Visual Studio allows you to try your code step-by-step. This process is called debugging.

Set up Visual Studio and the Codeasy Extension!

Follow these 8 simple steps to set up Visual Studio and the Codeasy extension.

  1. Find a computer with Microsoft Windows 7/8.1/10/11. Codeasy extension that you will install in this lesson runs only on Windows.

  2. Install Visual Studio 2022 Community Edition. Make sure you check ".NET Desktop Development" and ".NET 5.0 Runtime" during the installation. You can download Visual Studio here.

    Visual Studio 2022 installation instructions dotnet runtime version select
  3. Create a C# console application by clicking File > New > Project or by clicking "Create project" on the home screen.

    Creating console project

    In the resulting window, choose C# in the left list and Console in the right one. You will be presented with Console App option for the project type. Select it and press "Next". Click next, enter a Name for your project (we use SaveTheWorldWithCodeasy in the example below). You can only use Latin characters, and no spaces are allowed. Click OK when finished.

    Creating console project Finishing console project

    It is also important to choose .NET 5 Framework. Then click "Create" and your project is created!

    Finishing console project
  4. Run your first program. When you finish Step 3, a new project opens with a new file, Program.cs, open for editing.

    Take a minute to explore the environment. The main window is the Code Editor, which is where you write the code. A smaller window to the right, the Solution Explorer, provides a tree view of the project from which you can choose the files that you want to edit.

    C# project created

    Now that you're acquainted with the environment, let's run our first program. Start with some optimism - insert the following code into the main method:

    Console.WriteLine("I write code as professional programmers do!");

    Then press Ctrl+F5 on the keyboard, and you'll get the program output in the console:

    C# console output

  5. View the compiler output. As you know, when you make mistakes in the code, C# lets you know. The thing that generates those error messages that appear is called the compiler. We'll come back to the definition of the compiler, but for now, let's find where compiler errors are printed. For example, put an intentional mistake in your code by deleting the semicolon at the end of the Console.WriteLine command:

    Console.WriteLine("I write code as professional programmers do!")

    Press F5 (or if that doesn't work, Ctrl+F5) on the keyboard, and you'll get the following warning:

    build errors in visual studio

    Select the Do not show this dialog again check box and click No. The next time it encounters an error, Visual Studio will show you the compiler errors in the Error List panel, as shown below.

    C# console output

    If you double-click the error message, the cursor will be placed at the location where that error occurred. Magic! For now, put the semicolon back in your code.

    Before we continue, I want to clarify one thing. You'll often hear the term Build, as in build a project, build a solution, etc. The easiest way to think about it for now will be as a check for errors. Code building is a process of finding misspellings in commands and other things that the compiler doesn't understand. The term Build is sometimes referred to as compilation. In Visual Studio, you build your code by pressing Ctrl+Shift+B or by right-clicking on the project name in the Solution Explorer and clicking Build Project. This action checks for errors but does NOT run your program. To run a program, you must press F5 or Ctrl+F5, or click the Start button in the top menu.

  6. Install the Codeasy Visual Studio Extension. In Visual Studio 2022, click Extensions > Manage Extensions. In the resulting window, choose Online in the left menu. Then type Codeas in the search field. The Codeasy extension should appear on the screen.

    Visual Studio install extensions

    Click Download to begin the installation, and then close Visual Studio. In the dialog window that appears, click Modify.

    Install Visual Studio Codeasy extension

    Find your project (SaveTheWorldWithCodeasy) in the Recent list and select it.

    Open solution in Visual Studio

    Once your project loads, click View > Other Windows > Codeasy Extension from the toolbar.

    How to find Codeasy extension

    The extension window will open at the bottom of the screen. There are tabs at the bottom of the window that let you change what is shown in the window (Error List, Breakpoints, etc.). The thumbtack button in the upper right corner of the extension window (shown circled in green in the following image) will pin the Codeasy extension window so that it is always visible on the screen.

    How to find Codeasy extension

    Once you're logged in, you'll see three lists in the extension window: Chapter, Lesson, and Task.

    Codeasy Visual Studio extension first view

    After you activate a new chapter, click the Refresh button (shown below) in the extension to update the Chapter view.

    Codeasy Visual Studio extension refresh

  7. Load and solve tasks. Time to do something awesome! First, fix all mistakes in our experiments. Remember, to check for mistakes (or compile), press Ctrl+Shift+B or right-click the project name in the editor and select Build. Then click on the third chapter, third lesson (Visual Studio Extension), and the first task (First task from VS). This is how you choose a specific task in extension. Finally, click the Load button (shown below) to load the task contents into your SaveTheWorldWithCodeasy project. Note that you must have an internet connection to load tasks from Codeasy.

    Codeasy Visual Studio extension load task

    Upon loading the task contents, you'll see that folders with the chapter and lesson names were added to your project in the Solution Explorer. There will also be a new file with the name FirstTaskFromVs.cs that includes some predefined code. If you close a tab in the code editor by mistake, don't worry! Just double-click the file name in the Solution Explorer to open the file again.

    Codeasy Visual Studio extension loaded task

    Find and read the task description (shown circled in orange below).

    Now, try to run the task by pressing Ctrl+F5. As you'll see, the console window will open with just the phrase "Press any key to continue...". This is because the task currently does not output anything to the screen. Completing the task is your job!

    Codeasy Visual Studio extension check task

  8. Check your solution. Let's try to check this task. Press the Check button (circled in red above). Because you have not completed the task (yet!), you'll receive a FAIL prompt.

    Codeasy Visual Studio extension task fail

    Let's change a few things. Solve the task by adding the specified text using a Console.WriteLine(); command, and click the Check button again. If your solution matches the task, you'll receive a SUCCESS prompt as shown below.

    Codeasy Visual Studio extension task success

    The icon for that task in the extension window will also change to a green checkmark, indicating that you've completed the task. Good job! You can now check your leaderboard position on the Codeasy website.

    Codeasy Visual Studio extension task success

Here is a summary of how to start solving tasks with the Codeasy Visual Studio Extension:

  1. Download and install Visual Studio 2022 Community Edition.
  2. Create a .NET Console application.
  3. Install the Codeasy Visual Studio extension.
  4. Make sure you're doing your work in an open solution while working with the extension.
  5. In the extension window, choose a chapter, lesson, and task, and then click the Load button to download predefined code for that task.
  6. Solve the task and test your solution by pressing Ctrl+F5 to open a console with your output.
  7. Click the Check button to verify your solution.
  8. Enjoy!

The following is a list of things you can do with the Codeasy Visual Studio extension:

  1. Load a task's code.
  2. Check your solution.
  3. Create a library of all tasks that you've solved locally on your PC. You can find them in the Solution Explorer in a corresponding folder.

Finally, here are some things that are good to know about Codeasy's Visual Studio extension:

  1. Visual Studio will run the task that you've chosen in the extension. If you want to run another task, click on it in the extension window.
  2. The extension does NOT support class renaming. Do not rename classes unless otherwise specified.

At Codeasy we believe that learning should be fun and engaging. Please reach out to us to share your feedback and collaboration ideas.