+ 1
Can a variable begin with a number after an underscore? For example like : _1name
3 odpowiedzi
+ 1
Yes :)
+ 1
The underscore is simply a convention; nothing more. As such, its use is always somewhat different to each person. Here's how I understand them for the two languages in question:
In C++, an underscore usually indicates a private member variable.
In C#, I usually see it used only when defining the underlying private member variable for a public property. Other private member variables would not have an underscore. This usage has largely gone to the wayside with the advent of automatic properties though.
Before:
private string _name;
public string Name
{
get { return this._name; }
set { this._name = value; }
}
**************************************
After:
public string Name { get; set; }
**************************************
0
to add to what the above poster said and iterate on the convention aspect of this question it is different for everyone. I typically use underscore when declaring global variables