开发者

Versions of Enum

public enum ObjectType { Country=0, Region=1, Province=2, City=3, Hotel=4 }

I have two applications in two language versions, and this Enum is displaying in some place, so depends of language version I wanna displaying correct version of Enum

in german version instead Country Land etc.

This Application are using the same websercice which h开发者_如何学JAVAas declaration of this enum.

ADDED

I have a datagridview and list of objects which classes has field ObjectType and I must display this pool in datagridviev, so it's a problem


Enum keys are part of your code, just like method names. They're not supposed to be localized.

If you need to localize things, don't display the enum keys to the user directly. Map them to localized values using a resource file.


Enum values are supposed to be for programming logic, and are usually not used for UI output. You should serve the ObjectType enum in default English (like most programming keywords are) and let the WebService consumer do the translation to the correct language.


What about a solution like this?

public enum ObjectType 
{ 
    Country=0,
    Land=0, 
    Region=1, 
    ...
} 

By the way, as someone said, Enums are not supposed to be localized. Try for some other good solution. If you share more details, we will try to suggest.


Best would be to implement database or configuration file mapping between enum and string representation. It will help you not only for localisation, but also enum values which hase two words


there is the answer:

Can my enums have friendly names?

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜