Is there away that i can create property or a variable that has data- as the prefix? (because by default the compiler wont let me!)
Asked
Active
Viewed 121 times
1 Answers
2
Short answer: no.
Long answer: according to C# Specification an identifier must start with a letter (capital or lowercase) or underscore. After the first letter it may contains numbers, letters and underscore.
These rules exists because the compiler is not able to recognize if you are declaring a variable (e.g. data-part
) or you are trying to accomplish an operation (in this case a subtraction)

Tinwor
- 7,765
- 6
- 35
- 56
-
`data-` actually starts with a letter, problem is that identifier can not contain `-` symbol. – tchelidze Feb 07 '16 at 14:31
-
-
You can use [all kinds of random Unicode characters](http://stackoverflow.com/questions/950616/what-characters-are-allowed-in-c-sharp-class-name) if you want, but don't expect it to play nicely with the IDE. In keeping with the standard .NET naming convention, you should call the property `AttrName`, using PascalCase. @abba – Cody Gray - on strike Feb 07 '16 at 15:18