1

I created an extenstion method on my custom enum type like

public static class GetLocEnum
{
    private static string Translate(this MyEnum e, int lang)
    {
        string res = string.Empty;
        if (lang == 1) 
        {
            switch (e)
            {
                case MyEnum.OptionOne:
                    res = "some title";
                    break;
                case MyEnum.OptionTwo:
                    res = "some title 2";
                    break;
                case MyEnum.OptionThree:
                    res = "some title 3";
                    break;
            }
        }
       // more if's ...
       return res;
    }
}

Why I'm not able now to use this as extension in MyEnum.Translate() ?

Jon Skeet
  • 1,421,763
  • 867
  • 9,128
  • 9,194
user1765862
  • 13,635
  • 28
  • 115
  • 220
  • For reference, here is a [good SO question](http://stackoverflow.com/questions/17380900/enum-localization) about localization and enums. The accepted answer shows a nice, flexible, approach to localizing your individual enum values. – Jason Evans Nov 09 '15 at 09:49
  • 1
    chage the access modifier to `public` – Michael Mairegger Nov 09 '15 at 09:49
  • 1
    You should always show a *complete* example (you don't actually show how you're trying to call it) along with the exact error message you're receiving. If this is in the same project, I'd expect the compiler error message to be helpful. – Jon Skeet Nov 09 '15 at 09:49

1 Answers1

6

It's just because it's private! Change it to public if you want to use it elsewhere.

Perfect28
  • 11,089
  • 3
  • 25
  • 45