Windows Develop Bookmark and Share   
 index > Windows Forms General > variables with preceeding underscore line ( _ )
 

variables with preceeding underscore line ( _ )

Is there any significance of the variables which are preceeded with an underscore line?

example: _variableName
MigrationUser 1  Wednesday, January 19, 2005 12:46 PM
In what context?  The underscore has no meaning in and of itself.

I use underscores for class-level private members as it makes it a bit easier for me to tell what the scope of the vaiable is with just a glance (and it saves me from having to be creative when trying to differentiate parameters/local variables from class-level variables).

i.e.:void DoStuff(string id)
{
   _id = id;
}
It is used by some libraries to identify members that are not meant to be used directly.  Also, some languages discourage their use because compilers will often use them in the identifiers for automatically generated members, possibly casuing a name collision, but this isn't really a problem with smarter compilers.
MigrationUser 1  Wednesday, January 19, 2005 4:56 PM
Yes, I think that the context in these cases is for identifying local variables. 

Thanks for the input.

MigrationUser 1  Thursday, January 20, 2005 11:22 AM

You can use google to search for other answers

Custom Search

More Threads

• Adding PictureBox on top of another PictuBox
• Losing my events.....
• which is best to go to a new form?
• execute click button's event as a reguler method
• Checking for special characters in text control
• How to access data from .csv file from a network using Visual basic 2008
• Raise and UnRaise Control.MouseXXX event
• How visual studio manages Project's references
• vs2008 Menus
• Data Loading Popup Window