Supporting globalization or I18N for Constant Expressions RRS feed

  • Question

  • HI,

    Either in C# or VB.NET , in Switch Case statements where we have Constant Expression values being used for each case statement , how can we support globalization for that.


     switch (aa)
                case "Hello":
                     alert("The city of ");


    In place of "Hello" we cant use GetLocalResourceObject API to read the string from resource file as we "Hello" is a constant expression that is evaluvated in compile time.

    So need help in:

    1) confirmation towards the above logical understanding.

    2) how to support globalization for the above constant expression senario.


    Tuesday, January 15, 2013 3:51 AM


  • You can always fall back to if/else.

    if (0 == string.Compare(Globalize("hello"), aa, true))
       alert ("The city of ");
    else if (0 == string.Compare(Globalize("goodbye"), aa, true))
       alert ("foo");
    else   // ...

    This signature unintentionally left blank.

    • Proposed as answer by Mike Feng Wednesday, January 16, 2013 6:08 AM
    • Marked as answer by Mike Feng Monday, January 21, 2013 2:37 AM
    Tuesday, January 15, 2013 12:30 PM