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

Using the Visual Studio Integrated Development Environment

Using the Visual Studio IDE

Written By on in C#

789 words, estimated reading time 4 minutes.

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.

Using Visual Studio Series
  1. Getting Started with Visual Studio
  2. Using the Visual Studio Integrated Development Environment
  3. Using the Visual Studio Debugger
  4. XML Documentation in Visual Studio
  5. Using Microsoft .Net Command Line Tools
  6. What is an Assembly in Microsoft .Net?
  7. Creating and Using a .NET Assembly in C#
  8. Creating and Implementing Satellite Assemblies
  9. Creating Strong Named Assemblies in Microsoft .Net
  10. Visual Studio Task List
  11. Resources and Localisation in C# Projects
  12. Localising Microsoft .Net Applications with C#
  13. Using Resource Files in C# Applications
  14. Using XSD Tool to Generate Classes from XML
  15. 10 Visual Studio Tools You May Not Know About

This article relates to an old version of the .Net Framework. While the contents are still relevant, future versions of the framework may change, or improve upon, the contents of this article.

For this tutorial, we will be using the free version of Microsoft Visual C# Express to demonstrate the features of the development interface, although there is not a great difference between Visual C# Express and the full Visual Studio.

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:

  • Keywords are blue
  • Comments are green
  • Strings are red/brown
  • Classes are gray

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.

Start off my deleting the Console.WriteLine line, then just type 'C'. Notice a pop-up window with a list of items beginning with 'C', also note that Console is the highlighted item. This is the item that Visual Studio thinks you are most likely to use in the current context. We can now press Enter, or just '.' and IntelliSense will type the rest of the word for you, and bring up another selection box, this time with WriteLine selected.

IntelliSense demonstration
IntelliSense demonstration

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

Summary and Conclusions

In this tutorial, we saw how the Visual C# IDE is very clever at predicting what you are going to type, and it is able to improve your productivity by reducing the amount of time spent coding. We also saw how regions and blocks can be collapsed to de-clutter the code window.

In the next tutorial, we will have a look at the task list and see how we can use it to help plan our development.

Last updated on: Saturday 24th June 2017

 

Comments

There are no comments for this post. Be the first!

 

Leave a Reply

Your email address will not be published.





If you find something abusive or that does not comply with our terms or guidelines please flag it as inappropriate.

Copyright © 2001-2018 Tim Trott, all rights reserved. Web Design by Azulia Designs

This web page is licensed for your personal, private, non-commercial use only.

Disclaimer, Privacy & LegalSitemapContact Me