Wrox Programmer Forums
|
BOOK: Beginning Object-Oriented Programming with C#
This is the forum to discuss the Wrox book Beginning Object-Oriented Programming with C# by Jack Purdum; ISBN: 978-1-1183-3692-2
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning Object-Oriented Programming with C# section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 6th, 2014, 02:52 PM
Registered User
 
Join Date: Jan 2014
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default VC# removes comments????

As I was working my way through one step at a time and learning what the VC# is doing to write the code behind everything so I understand the path of the data, just as I caught on, and got the editor to work properly (all user issue) and was commenting away, such and such per line of code so I could make any changes to variables I wanted.....even thou I learned the properties section will do all that for me.....

Anyway I added some more objects and the program removed all of ....just my...comments. Any way to turn that off? I really want to have those comments so I can refer back quickly.
Thanks
 
Old January 14th, 2014, 11:50 AM
Friend of Wrox
 
Join Date: Sep 2008
Posts: 234
Thanks: 0
Thanked 32 Times in 30 Posts
Default Debug code

There is no way to arbitrarily remove comments from a program. However, given that comments are used to explain what a specific statement or section of code is doing, they probably should be left there all the time. I realize your comments are serving a different purpose.

If you have a section of debug code that you want in while you're testing some code, but want it removed from the final versions, there is an easy way to do that. Such code, called "scaffolding code" can be removed by something like the following:

Code:
int DEBUG = 1;   // Place outside of any method so it's global scope

// ...a bunch of code...

if (DEBUG) {      // The section of scaffolding code that you want to remove
   MessageBox.Show("The string looks like: " + myData);
}
The way the code is above, you will always be able to view myData at that point in the program. You can add any code you wish in the if statement. Obviously, using the debugger makes viewing myData easy. However, sometimes you want to initialize a variable with a known set of data while testing the code, but remove it when finished. This approach gives you an easy way to toggle the code into and out of the program. When you have the code stabilized, just set DEBUG to 0 and the if statements are no longer executed.

While this is not the answer you wanted, it does allow you to toggle code into and out of a program easily should the need arise.
__________________
Jack Purdum, Ph.D.
Author: Beginning C# 3.0: Introduction to Object Oriented Programming (and 14 other programming texts)
 
Old January 15th, 2014, 10:26 AM
Registered User
 
Join Date: Jan 2014
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I remember the scaffolding coding from the book on Arduino C.

Thank you for your explanation





Similar Threads
Thread Thread Starter Forum Replies Last Post
Programming windows with VC 2005 or VC 2008 phuc_tran C++ Programming 2 December 4th, 2009 10:04 AM
Migrating from VC++ 6 to VC++ 2005 raghud Visual C++ 2005 1 November 4th, 2009 06:13 AM
Custom TreeItemRenderer removes custom component maulik33 Flex 0 January 15th, 2009 11:51 PM
Comments janees ASP.NET 1.0 and 1.1 Professional 1 April 8th, 2007 09:27 PM
convert VC++ 5.0 project to VC++ 6.0 MIDL ERR mdahd90943 Visual C++ 0 May 26th, 2005 08:57 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.