Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • Book Overview & Buying Visual Studio 2013 and .NET 4.5 Expert Cookbook
  • Table Of Contents Toc
Visual Studio 2013 and .NET 4.5 Expert Cookbook

Visual Studio 2013 and .NET 4.5 Expert Cookbook

By : Abhishek Sur
4.3 (3)
close
close
Visual Studio 2013 and .NET 4.5 Expert Cookbook

Visual Studio 2013 and .NET 4.5 Expert Cookbook

4.3 (3)
By: Abhishek Sur

Overview of this book

If you are a Visual Studio 2013 or .NET developer who would like to sharpen your existing skill set and adapt to new .NET technologies, this is the book for you. A basic understanding of .NET and C# is required.
Table of Contents (9 chapters)
close
close
8
Index

Introduction

Being one of the best IDEs available, it may often seem that our knowledge about Visual Studio falls short when some special circumstances appear. Visual Studio provides hundreds of tools inside it and also some tools as extensions to help programmers develop software in the best possible ways. It incorporates features such as refactoring, code analysis, clone code finder, and so on to let a developer write better code and have the best experience while inside the IDE. Visual Studio has been so popular that it is not constrained to just software development; some people use it to edit documents and images, or even to publish content. It is so user friendly and easy to use that anyone can work on it at a basic level.

Debugging is the most important part of any application development process. People like to start debugging a program while developing code. Debugging is a process that lets you have a quick look at the current state of a program by walking through your code step by step and letting you identify what exactly is happening while the program is running. Developers expect an IDE to give them as much information as possible during a certain state of the program. Visual Studio has taken every step to improve the debugging experience of the IDE and make small tools to let developers find better ways to quickly find the possible problems in code (if any).

After opening the IDE, it is often the case that people start typing some code. But, it is unlikely that developers will always finish writing the code before they start debugging. After some part of the development is done, they tend to start debugging it to have a better understanding of the logic and functionalities. Some people start debugging even before they have written a single line of code. So debugging is not just identifying bugs, it is determining the merits and demerits of the code as well. Debugging inside Visual Studio is perhaps the best selling point of the IDE.

Visual Studio separates the environment layout completely while debugging. After writing your code, when you press F5 on the keyboard or go to Debug | Start Debugging, Visual Studio adjusts the whole layout of the window and creates an environment that is best suited for debugging; for instance, when you are in the debug mode, generally the Solution Explorer, Toolbox, the Properties window, and so on get hidden. Instead, windows such as IntelliTrace, Autos, Locals, Watch, and Call Stack automatically open inside the IDE and get docked/adjusted to the layout inside the IDE. The IDE is smart enough to store the layout information of all the opened windows inside it when the debugging session is closed by the user for a particular project. Therefore, when you start debugging again, the IDE provides you an environment that is exactly adjusted to the left-hand side when the previous debug session is closed.

In this chapter, we will try to demonstrate some of the important debugging tools available in the IDE. Let's start with a simple class that consists of a few properties and methods:

public class TestClass
{
  public int Start { get; set; }
  public int End { get; set; }

  public TestClass(int start, int end)
  {
    this.Start = start;
    this.End = end;
  }
  public int GetSum(int start, int end)
  {
    var sum = 0;
    for (var i = start; i <= end; i++)
      sum += i;
    return sum;
  }

  public string GetMessage()
  {
    var sum = this.GetSum(this.Start, this.End);
    return string.Format("Sum of all numbers between {0} and {1}  is {2}", this.Start, this.End, sum);
  }
  public void PrintMessage()
    {
      var message = this.GetMessage();
      Console.WriteLine(message);
      Console.ReadKey(true); 
    }

  }
  class Program
  {
    static void Main(string[] args)
    {
      var tclass = new TestClass(20, 30);
      tclass.PrintMessage();
    }
  }
}

The dummy code that we are using here has a TestClass, which takes two arguments and stores data in the data members Start and End. GetSum is a method that sums up all the integers between Start and End. The GetMessage returns a message after calling Sum with Start and End, and finally PrintMessage prints the message on the console.

The program creates an object of TestClass and calls PrintMessage with 20, 30. If you run the program, it shows 275 on the console.

CONTINUE READING
83
Tech Concepts
36
Programming languages
73
Tech Tools
Icon Unlimited access to the largest independent learning library in tech of over 8,000 expert-authored tech books and videos.
Icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Icon 50+ new titles added per month and exclusive early access to books as they are being written.
Visual Studio 2013 and .NET 4.5 Expert Cookbook
notes
bookmark Notes and Bookmarks search Search in title playlist Add to playlist font-size Font size

Change the font size

margin-width Margin width

Change margin width

day-mode Day/Sepia/Night Modes

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Confirmation

Modal Close icon
claim successful

Buy this book with your credits?

Modal Close icon
Are you sure you want to buy this book with one of your credits?
Close
YES, BUY

Submit Your Feedback

Modal Close icon
Modal Close icon
Modal Close icon