How can I determine the resource identifiers?

The Resource Names page on MSDN says the following.

Use the dot separator (".") To define identifiers with a clear hierarchy.

For example, names such as Menus.FileMenu.Close.Textand Menus.FileMenu.Close.Colorcorrespond to this guide.

How should I do it? When I try, they tell me that the dot is not valid in the resource identifier, for example.

Disappointment.

I can understand why it is not valid [1] so I always assumed that it was impossible to determine resource identifiers and have never tried so far ... but MSDN says I can, what am I missing?

[1] From a glance at an automatically generated file Resource.Designer.cs.

+5
source share
1 answer

I saw it too, and it looks like it has been around for several years.

A 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 stated in the question). However, the generator will replace the dot with an underscore so that you still get a valid class with a typical type.

I usually just replace the dot with an underscore. It is strange, however, that they still have not changed this in the guidelines. (Or maybe I missed something?)

+2
source

All Articles