C#
  Home arrow C# arrow Testing and Debugging a Windows Forms Appl...
Iron Speed
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
ASP Web Hosting  
ASP.NET Web Hosting 
Dedicated Servers 
Actuate Whitepapers 
VeriSign Whitepapers 
Windows Web Hosting
 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
C#

Testing and Debugging a Windows Forms Application
By: Murach Publishing
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 11
    2006-07-06

    Table of Contents:
  • Testing and Debugging a Windows Forms Application
  • How to get help information
  • How to run a project
  • How to test a project
  • How to debug runtime errors
  • Perspective

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT

    At the virtual BlackBerry Technical Seminar 2008, you can ask your development questions directly of Research In Motion® (RIM) experts, and take advantage of learning opportunities designed uniquely for BlackBerry solution developers. Register Today!

    Testing and Debugging a Windows Forms Application


    (Page 1 of 6 )

    This article shows you how to revise, test, and debug a Windows form application. The third of three parts, it is excerpted from chapter three of the book Murach's C# 2005, written by Joel Murach (Murach, 2005; ISBN: 9781890774370).

    How to refactor code
     
    As you work on the code for an application, you will often find that you want to revise your code. For example, you may want to change a name that you’ve used to identify a variable in your code to make the name more meaningful and readable. However, if you change the name in one place, you need to change it throughout your code. This is known as refactoring, and Visual Studio 2005 includes new features that make it much easier to refactor your code.

    Figure 3-11 shows how you can use Visual Studio to quickly and easily change the names that you use within your code. In this figure, for example, the first screen shows the Code Editor after the name of the subtotal variable has been changed from subtotal to total. Here, a bar appears under the last letter of the newly renamed total variable. Then, the second screen shows the smart tag menu that can be displayed by pointing at the bar and clicking on the drop-down arrow that becomes available.

    At this point, you can select the first command to rename the variable throughout the application. Or, you can select the second command to preview the changes. If you select the second command, a Preview Changes dialog box will be displayed. Then, you can preview the changes and deselect any changes that you don’t want to make.

    Although this figure just shows how to change a name that’s used by the code, you can also use Visual Studio’s refactoring features to modify the structure of your code by extracting methods, encapsulating fields, and so on. To do that, you often begin by selecting a block of code. Then, you can right-click on the code and select the appropriate refactoring command. Or, you can select the appropriate command from the Refactor menu.

    If you already have experience with another object-oriented language, these refactoring features should make sense to you. If not, don’t worry. You’ll learn more about these features as you progress through this book.

    The bar that appears under a renamed variable

      decimal total = Convert.ToDecimal (txtSubtotal.Text);

    The menu that’s available from the bar


    The Preview Changes dialog box


    Figure 3-11.  How to refactor code

    Description

    • The process of revising and restructuring existing code is known as refactoring. Visual Studio 2005 provides many new features that make it easier to refactor your code.
    • When you change a name that’s used in your code, Visual Studio displays a bar beneath the modified name. Then, you can display a smart tag menu by moving the mouse pointer over the bar, and you can click on the drop-down list to display a menu that contains the appropriate refactoring commands.
    • You can also use Visual Studio’s refactoring features to modify the structure of your code by extracting methods, encapsulating fields, and so on. To do that, you often begin by selecting a block of code. Then, you can right-click on the code and select the appropriate command, or you can select the command from the Refactor menu.
    • Some refactoring commands display a dialog box that lets you preview the changes before you make them. Then, you can deselect any changes that you don’t want to make.

    More C# Articles
    More By Murach Publishing


       · This article is an excerpt from the book "Murach's C# 2005," published by Murach. We...
     

    Buy this book now. This article is excerpted from chapter three of the book Murach's C# 2005, written by Joel Murach (Murach, 2005; ISBN: 9781890774370). Check it out today at your favorite bookstore. Buy this book now.

    C# ARTICLES

    - Exceptions in C#
    - Overriding versus Overloading
    - Value Types and Reference Types
    - Defining Member and Type Visibility
    - Managing Files in C#
    - Working with Windows Registry in C#
    - Lossless Image Resizing in C#
    - Lossless Image Converting in C#
    - Creating an RSS Feed with ASP.Net Written in...
    - Polymorphism in C#
    - Inheritance in C#
    - C# Events Explained
    - C# Delegates Explained
    - C# StreamReader and StreamWriter Explained
    - C# FileStream Explained





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway