Click here to Skip to main content
15,899,026 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi Good Day,

I would like to ask..

I met this code and I tried to run... they say it is already working.. but I encountered an error..

C#
const string my.var  = " "; 


I encountered an error in Visual Studio, but my colleagues told me that it is working.. I just can't figure it out...

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 28-Feb-16 17:10pm
v2

1 solution

"Dot" is not a valid character in a symbol (such as a variable name). It represents the membership operator. So my.var reads as "the member var of object/struct/whatever my ".
 
Share this answer
 
Comments
berrymaria 1-Mar-16 3:53am    
Hi Sir, this is the example.. Please advise? This line runs in VS 2013..

https://dl.dropboxusercontent.com/u/28759525/middle%20dot.png

but doesn't in VS2015/2015 ..
Peter_in_2780 1-Mar-16 5:50am    
The character in your example is NOT "dot" (\u002e). I suggest your VS2013 environment is different, probably in terms of language/culture settings. This may be in VS or in Windows. If you are going to post a question like this, you should show us the exact code involved, not your "translation" of it, which is totally misleading. Also, you should post the exact error message from the failure.
berrymaria 1-Mar-16 20:21pm    
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";

Error CS1056 Unexpected character '・'

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