The page Names of Resources on MSDN says the following.
Do use the dot separator (".") to nest identifiers with a clear hierarchy.
For example, names such as
Menus.FileMenu.Close.Text
andMenus.FileMenu.Close.Color
conform to this guideline.
How do I do this? When I try to, I'm told a dot is not valid in a resource identifier, like this.
I can understand why it's not valid[1], which is why I always assumed it wasn't possible to nest resource identifiers, and never tried until now... but MSDN says I can. What am I missing?
[1] From looking at the auto-generated Resource.Designer.cs
file.
I've seen this too and it looks like it has been around for a few years now.
The strong type generator generates a strong typed class, and maps each resource to a property of that class. The resource name (identifier) will be used as the name of the property. An identifier with a dot character is not valid in C# (as you declared in the question). However, the generator will replace the dot with underscore so you still get a valid strong typed class.
I usually just replace the dot with an underscore. It's strange though that they still haven't changed that in the guidelines. (Or maybe I have missed something?)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With