Click here to Skip to main content
15,891,993 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Good Day,

I would like to ask..

I met this code and I tried to run in VS 2013 in it is okay..

C#
public const string my●var  = " "; 


But when I tried to run in VS 2015,

Please help. Thanks.

What I have tried:

Already researched about const variable name with dot.. but can't find any..

+++
No error when using VS 2013 Express, Errors on VS 2012, or 2015
Posted
Updated 29-Feb-16 21:31pm

If this code compiles on 2012 and 2013 (I doubt that), than it is a bug...
According to C# specification such a sign can not be part of of a variable name (see 2.4.2 Identifiers)...
For sure it does not compile in 2008/2010/2015...
 
Share this answer
 
Just to complete what Peter says: that code doesn't compile under VS2013 either:
C#
Error	1	Unexpected character '●'

It's not a legal character in variable names in C# of whatever vintage.
 
Share this answer
 
Comments
OriginalGriff 1-Mar-16 4:12am    
The example doesn't in my version of VS20013 - I get the error you see above.
The dropbox version I can't check - I have no way to type in those characters.
berrymaria 1-Mar-16 4:26am    
Hi Sir, public const string バー·ー = "0";

public const string バーー = "0"; has no error, but if there is · error now occurs...
OriginalGriff 1-Mar-16 4:35am    
I copy both lines into VS2013.
I get an error on the first one, and noth on the second.
You cannot use that character in variable names, not in VS2010, VS2013, VS2015, ...
It is not a valid character!
See here:
https://msdn.microsoft.com/en-gb/library/aa664670%28v=vs.71%29.aspx?f=255&MSPPError=-2147217396
berrymaria 1-Mar-16 20:19pm    
Hi Sir, I tried this..

Works in VS 2005/2012.. (I set the Encoding in VS2005 to Unicode - CodePage 1200)
public const string バー・ = "0";

Errors in VS2015:
public const string バー・ = "0";

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900