Development Environment Installation

Note: The video was recorded with Visual Studio 2017. The following steps are for Visual Studio 2019, but they are the same. You can find a video with Visual Studio 2019 here

1 - Download and Install Visual Studio 

In this first entry, we will start with the basics, but also the most important part: installing and setting up your development environment. 

A development environment is the application we use to program.

Specifically, to program in .NET, we will use Visual Studio, which you can download here in Spanish for free and officially.

 

Once on the link, download the Community version.

download visual studio 2019

What you download is the launcher for the installer. So, once downloaded, you need to open it and it will download the installer.

 

visual studio installer

When the installation finishes, the Visual Studio installer will open automatically. For example, if you have both the 2017 and 2019 versions, they will appear together in a single installer.

The window you see will be similar to the following, which contains a series of components that you can add to your Visual Studio.

You can add these components both individually and in packages, which is much more convenient. 

visual studio 2019 installation

For us, the only necessary package is the one that includes ".Net Core." Then click install.

The download size is rather large, about 7GB, so it may take a while. When finished, you'll see a "Launch" button in the launcher; clicking it (or searching it in the start menu) will open Visual Studio 2019.

2 - Creating an Application in Visual Studio

In the next window, you'll have several options.

  • Clone code (from a repository)
  • Open a project or solution
  • Open a folder
  • Create a new project

select visual studio project

In our case, we are interested in creating a new project.

Clicking on it will open another menu where you can specify what type of project you want.

In this window you can find several filters:

  • Recently used project type
  • Project language (in our case we will use C#)
  • Platform supported by the project type
    • It's not the same to program for Android as for iOS, and you can do it all from Visual Studio
  • Project type
    • Lets you create mobile, desktop, IoT applications, and many more

We need to select the first option: Console Application (.NET Core)

Click Next, and you will be prompted to enter a name for the project and the folder where it will be located. I recommend creating a folder in C:\ called projects, and storing all your work there. Finally, you need a name for your solution, usually the same as your project.

And that's it! This will create your first console application.

Why .NET Core

There are several reasons why I recommend using .NET Core. The main reason is it runs on all platforms: Windows, iOS, and Linux. This very website is programmed in .NET Core and running on a Linux server - I will prepare a video to show you the steps for this -

Another very important point, at least for me, is the IDE or development environment, which is Visual Studio. It has no rival in any other programming language.

3 - First "Hello world" application

As you can see, by default Visual Studio starts with a "hello world" 

static void Main(string[] args){    Console.WriteLine("Hello World!");}

If you click the "Play" button in Visual Studio, it will run the application and print "hello world"

 

It's that simple and easy to run your first "Hello world".

Before moving forward, note that when you create a new console project, a class called Program and a method called Main will always be created as the main ones. These can be changed, but the standard is not to do so.

4 - Program Structure 

To create a class you have to:

Right-click the project > add new item > select class

This will create something like the following:

class Vehiculo{}

Classes have methods and properties as their main elements, but can also contain events, delegates, or other classes inside them. We'll see this later. 

4.1 - Properties

Properties are attributes that contain a value at the class level.

class Vehiculo{    public decimal VelocidadMaxima { get; set; }}

As you can see in the example, the property definition contains:

  • Access modifier “Public”
  • Data type “Decimal”
  • Property name “VelocidadMaxima”
  • To set a value, a “set”
  • To read the value, a “get”
  •  

4.2 - Methods

Methods are code blocks whose purpose is to perform actions. 

The most common method in all classes is the constructor, which is written as follows: 

class Vehiculo{    public decimal VelocidadMaxima { get; set; }    public Vehiculo(decimal velocidadMaxima){        VelocidadMaxima = velocidadMaxima;    }}

As you can see, it is named the same as the class. Constructors are used to assign value to the properties in the class.
There are several options to set property values:

  • Assign the value directly in the constructor
  • Pass the value to the constructor
  • Use another method to assign the value
  • Assign the value directly once the class is instantiated

In our example, we will use passing the value to the constructor.

For the example, I will create another variable for fuel consumption per kilometer.

This will allow us to create another method that will return the total consumption for a certain number of kilometers.

class Vehiculo{    public decimal VelocidadMaxima { get; set; }    public decimal ConsumoPorKilometro { get; set; }    public Vehiculo(decimal velocidadMaxima, decimal consumoPorKilometro){        VelocidadMaxima = velocidadMaxima;        ConsumoPorKilometro = consumoPorKilometro;    }    public decimal ConsumoTotal(decimal kilometros){        return ConsumoPorKilometro * kilometros;    }}

In this case it's a bit different since the method right after the word "public" has another data type, which is the return value of the method. 

The Importance of Variable Names

It's important to take a moment here, since this is something junior programmers usually overlook: the name of properties/variables and methods.

It's important that both properties and methods have self-explanatory names. By this, I mean if you name a property "VelocidadMaxima" (MaximumSpeed), anyone reading the code later knows that this property contains the maximum speed. On the other hand, if you name a variable "xmx", no one will understand what that property does.

4.3 - Comments

Comments are blocks of text added manually to explain what the code is doing. If any part of your code is complex or confusing, you will need to add some. However, as I mentioned a moment ago, ideally, each variable, property, and method should have a clear, meaningful name so additional comments are not necessary.

There are 3 ways to add comments:

  • Single-line comments using “//”
  • Block comment “/* text */”
  • Function description “///” 
    • By pressing the backslash 3 times at the top of a function, the IDE will generate a comment block with:
      • <summary> to explain what the function does
      • <param> for each input parameter
      • <returns> to state the return value 
//single-line comment/*    Block comment*//// <summary>/// Indicates the amount of gasoline consumed /// </summary>/// <param name="kilometros">Indicate kilometers traveled</param>/// <returns></returns>

As you can see, if both variables and methods have suitable names, comments are not always necessary because the information is already clear.

4.4 - Access Modifiers

This section will be brief as I will make another video to explain everything in detail. For now, just to name and enumerate their characteristics.

An access modifier indicates how accessible your methods or properties are from other members or classes that reference them. 

The main ones are: 

  • public, no restrictions
  • internal, accessible only from within the same project
  • private, only accessible from within the same class
  • protected, from the class itself and its derived classes

By default, in .NET the access modifier is "internal"

4.5 - Namespace Declaration

What is a namespace?
A namespace is where we organize all classes and files in our project. Under the hood, it uses XML, which contains which classes are in each namespace and lets you use them without the "using" directive, which allows you to use classes from different namespaces (very commonly used). 

Namespaces allow us to avoid ambiguity with class names, since there cannot be two classes with the same name in the same namespace, but you can have them in the same project in different namespaces. 

This post was translated from Spanish. You can see the original one here.
If there is any problem you can add a comment bellow or contact me in the website's contact form

© copyright 2025 NetMentor | Todos los derechos reservados | RSS Feed

Buy me a coffee Invitame a un café