0

I have this code

Public decimal Amt2016 { get; set; }

But i need to set it like below

Public decimal 2016 { get; set; }  

I have tried and search in google, but i didn't get an actual answer, or is it possible to set two names for a property like that

[name="2016"]
Public decimal Amt2016 { get; set;} 

Can anyone please help me to find out the solution?

M.S.
  • 3,974
  • 1
  • 15
  • 37
dee pan
  • 141
  • 1
  • 4
  • Is it a class of model and represents a column in a database? – Roman Marusyk Apr 19 '16 at 09:34
  • 1
    You should ask yourself why you need a property called `2016`. This is simply a number without any further meaning. However within your Xml or JSON or whatever what should 2016 stand for? I assume its some kind of temporal data, not just a number so you´d better be off call it `Data2016` or `Amt2016` as you already did. – HimBromBeere Apr 19 '16 at 09:35

3 Answers3

4

This is not possible, as it would cause ambiguous calls all over the place, the reason you can use text as a variable name at all is because it would need to be in speech marks to be seen as a string, this on the other hand can be seen as a number. Take this for example

int 2016 = 12345;
int multiplied = 3 * 2016;

What calculation would be done here if we could name variables as numbers? Would the sum be 3 * 12345 or 3 * 2016?

Alfie Goodacre
  • 2,581
  • 1
  • 9
  • 23
0

You cannot start identifier name by number.

identifier-start-character:

  • letter-character
  • _(the underscore character U+005F)

Here is more info.

BWA
  • 5,314
  • 7
  • 29
  • 42
0

Most of the languages(As per my knowledge) doesn't allow to start identifier names with number or special characters except _(underscore) and so does .net. Simply you cannot do that.

error_handler
  • 1,183
  • 9
  • 19