C# String Resource Values as Enum String Part values?

Posted by JL on Stack Overflow See other posts from Stack Overflow or by JL
Published on 2010-06-04T10:00:32Z Indexed on 2010/06/07 4:12 UTC
Read the original article Hit count: 248

Filed under:
|
|

Using VS2010 and .net V4.0 I would like to achieve the following:

I already have 2 resource files in my project for 2 languages - English and Czech.

I must say Resource Management in .net is excellent, I am suprised even to get code completion when implementing a String for example:

string desc = Strings.ResourceManagerDesc

This gets the string associated with the current culture of the thread.

Now I am trying to create an Enum that can have the String portion of the Enum interpreted from the Strings resources. In the following way (This code DOES NOT WORK):

public enum DownloadStatus
{
 1 = Strings.DownloadState_Complete,
 2 = Strings.DownloadState_Failed,
 3 = Strings.DownloadState_InProgress
}

This is a made up example, but you can see the point here. Since the above code won't work, is there a best practice way to achieve what I want?

© Stack Overflow or respective owner

Related posts about c#

Related posts about resources