开发者

Why does the .NET runtime add underscores to my string?

开发者 https://www.devze.com 2023-03-13 15:23 出处:网络
I store my application settings the C# way (Properties.Settings.Default.Save();). The settings are then stored by the C# runtime in the folder:

I store my application settings the C# way (Properties.Settings.Default.Save();). The settings are then stored by the C# runtime in the folder:

C:\Users\UserName\AppData\Local\My_Company_Name

The strange thing is that I entered "My Company Name" as the Company-property in Visual Studio ([assembly: AssemblyCompany("My Company Name")]).

S开发者_C百科o, where do the underscores come from? I've seen other apps creating folders with blanks...


The problem is that you are adding a property named "My Company Name". That is not a valid member name in C# so it is automatically transformed for you into a valid name: "My_Company_Name"

Same thing happens if you create a new project named "My Project". The default namespace of your project will not be "My Project" because its not valid. The default namespace VS will create for you will be "My_Project".

0

精彩评论

暂无评论...
验证码 换一张
取 消