Web Design that taps into the haromny and vision of your dreams.

Installing Visual Studio

By on in Coding

1,772 words, estimated reading time 9 minutes.

In this guide, we will look at how to download, install and configure Visual Studio and take a look at some of the features of the development environment.

Installation

Visual Studio 2017 is one of the easiest releases to install. Simply download the bootstraper, run and select the components you wish to use. We'll guide you through this process.

First, we need to check the system requirements. Visual Studio doesn't require a powerful machine, but it does require a significant amount of storage. You will need to be running Windows 7 or above.

You should have a 1.8 GHz or faster processor. Dual-core or better is recommended. 2 GB of RAM is the minimum, however 4 GB of RAM is recommended for optimum performance. Hard disk space. This is a large application with all its supporting development frameworks, libraries and tools. You will need up to 130 GB of available space, depending on features installed; with typical installations requiring 20-50 GB once installed. To improve performance, install Windows and Visual Studio on a solid state drive (SSD). Finally, you will need a video card that supports a minimum display resolution of 720p (1280 by 720); Visual Studio will work best at a resolution of WXGA (1366 by 768) or higher. You will also require Administrator rights to install Visual Studio.

If your system meets all these requirements we can go to the Microsoft website and download the installer.

Download Visual Studio

When the file has finished downloading, un the bootstrapper file to install the Visual Studio Installer. This new lightweight installer includes everything you need to both install and customize Visual Studio 2017. If you receive a User Account Control notice, click Yes.

Proceed to acknowledge the Microsoft License Terms and the Microsoft Privacy Statement and click Continue.

After the installer is installed, you can use it to customize your installation by selecting the feature sets that you want.

After you select the workload(s) you want, click Install.

Next, status screens appear that show the progress of your Visual Studio installation.

After the new workloads and components are installed, click Launch.

Using the Visual Studio IDE

In this tutorial, we will look at the Visual Studio Integrated Development Interface (IDE) and see how it makes our software development much easier. We will look at syntax highlighting, Intellisense and the toolbars. We will also look at different methods of running an application.

Syntax Highlighting

You have probably noticed that as you type the code in, Visual Studio will change the colour of the words. This is Syntax Highlighting and it the there purely to aid readability.

In general:

You can change these colours from within the program settings dialogue box if you would prefer different colours.

IntelliSense

Using our hello world application from the last tutorial, we are going to invoke IntelliSense and let it write code for us. If you types in the code in the last tutorial you will have seen IntelliSense, however, if you used copy and paste to insert the code, then now you will see IntelliSense.

You can use the arrow keys to select different items on the list. Scroll up to C and notice that Console is not on the list anymore. This is because IntelliSense will only offer suggestions based on the current context. For this little example, it will show all the methods and properties of the Console.

As we are looking at 'C' on the list, type in 'W' and the IntelliSense will jump back down to WriteLine. We can see by the icon (see below for examples) that WriteLine is a method we can call, so now type in an open parenthesis and IntelliSense will now give you the method name, a description of what it does and the parameters that it takes. Notice in the top left it says "1 of 19", this function has been overloaded and can take many different types of parameters. Don't worry about this just yet though, but you can use the up and down keys to look through them if you wish.

If for some reason IntelliSense does not automatically pop-up, you can use (Ctrl+Space) to have it pop-up at the cursor.

IntelliSense Icons

Here are a few of the common icons used in IntelliSense and what they mean. Don't worry if you don't understand the terms, they are all explained in later tutorials.

  • Classes
  • Methods
  • Properties
  • Namespace

Regions and Blocks

Visual Studio and Visual C# allow sections of code to be hidden away or collapsed. A section of code between two braces is called a region and can be collapsed or expanded by using the plus or minus icon near the gutter. The gutter is the grey column down the left-hand side of the code window. We will see what the gutter is used for when we look at Debugging.

You can collapse block level code that is nested within your methods, you can collapse the namespace, or you can collapse any block of code between the two.

The code does not get deleted, just hidden from view. This is very useful because it can hide away code that you may not be interested in and de-clutter the code window, so all your attention is on the code you are writing.

You can also define your own collapsible blocks of code by using the region and endregion keywords. To start a region, type #region , and at the end of the block of code type #endregion. The editor will now allow you to collapse this code.

#region myRegion
  Console.WriteLine("Please Enter Your Age:");  
  string myName = Console.ReadLine();
  Console.WriteLine("You Entered: " + myName);
#endregion

Visual Studio Task List

Visual Studio contains a nice feature that is a Task List. This view is similar to the Output view but shows all the tasks associated with the project or solution.

To view the task list select View menu then Task list (Ctrl+W, T). Tasks can be added with the "Create User Task" button and checked off when done.

Visual Studio Task List
Visual Studio Task List

The best feature for me, however, is its ability to automatically add and track TODO comments in your source code. When coding I often add a comment for things that need fixing or implementing in the future, the task list will pick up on these items so you can view them all and go directly to them.

using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;
 
namespace ConsoleApplication1
{
  class Program
  {
    static void Main(string[] args)
    {
      myArrayList myList = new myArrayList();
      // TODO: Genereate these dynamically
      myList.Add("iulwrg");
      myList.Add("3847987");
 
      Console.WriteLine(myList.ToString());
    }
  }
 
  class myArrayList : System.Collections.ArrayList
  {
    public override string ToString()
    {
      //HACK: This is a messy way, but works for now. Make it better.
      string result = "";
 
      //UNDONE: Removed for testing
      //string[] theItems = (string[])base.ToArray(typeof(string));
 
      foreach (string item in theItems)
      {
        result += " " + item;
      }
      return result;
    }
  }
}

This code will be scanned by the task list view and will pick up on the comment tags TODO, HACK and UNDONE.

You can define your own tags from the options screen (Tools » Options » Environment » Task List »Task List Options and add a comment token with the appropriate priority). FIXME is my personal favourite.

Visual Studio Task List - Comment Tags
Visual Studio Task List - Comment Tags

XML Documentation in Visual Studio

Visual Studio provides the ability to generate project documentation using comments in the code with embedded XML tags. These can be easily converted to a printable or human-readable document using style sheets.

The code editor will automatically provide the XML tags, all you need to do is to fill in the text as you code. XML documentation is slightly different from normal code comments in that it uses three forward slashes (///) instead of the two. The editor will provide a list of tags that you can use, including a title and description for methods.

By typing /// in front of a method, the editor will auto-complete a basic documentation layout for that method.

/// <summary>
///
/// </summary>
/// <param name="args"></param>
static void Main(string[] args)
{
}
 

All you need to do is fill in a summary of the method (what it does, called by, any data it returns etc...) and a description of the parameters it takes.

Using IntelliSense (Ctrl+Space) you can bring up a list of tags that can be used, including examples, see also and permissions.

It is good practice to comment your code as you progress.

A well-commented application permits a developer to fully understand the structure of the application and how the various aspects interact with each other. It also allows other developers to understand the project much quicker as they spend less time trying to work out what everything does.

When your code is complete and commented you can generate documentation by configuring the project properties.

Either right-click the project in the Solution Explorer or select Properties from within the Project menu. At the bottom of the build tab, there is an option to generate XML Documentation. Just enter a path for the documentation to be stored within. It will default to your project directory + "bin/debug/.xml".

You can also use the command line tool, csc.exe, to generate a documentation file:

csc program.cs /doc:my-xml-documentation.xml

Additionally, the text within the

tags are used by IntelliSense as the method description when prompting for info in the code designer. If you are developing code that will be reused by different people it is highly recommended that each method has at a minimum a summary section.

IntelliSense demonstration
IntelliSense demonstration

The resulting XML from the documentation isn't very readable to humans, but we can use an XML transformation to generate an HTML version. There is a good example style sheet on codeproject.com to download and use.

Last updated on: Wednesday 10th October 2018

 

Comments

Have a question or suggestion? Please leave a comment to start the discussion.

 

Leave a Reply

Please keep in mind that all comments are moderated according to our privacy policy, and all links are nofollow. Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.

Your email address will not be published.