Can a variable begin with a number after an underscore? For example like : _1name | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Can a variable begin with a number after an underscore? For example like : _1name

19th Feb 2017, 7:00 PM
Bassel AbdelSabour
Bassel AbdelSabour - avatar
3 Answers
+ 1
Yes :)
19th Feb 2017, 7:14 PM
Liam Keegan
Liam Keegan - avatar
+ 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; } **************************************
19th Feb 2017, 7:18 PM
Pablo Zirilli
Pablo Zirilli - avatar
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
20th Feb 2017, 5:38 AM
Dylan Parker
Dylan Parker - avatar