none
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.

    Example:

     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.

    Thanks

    Tuesday, January 15, 2013 3:51 AM

Answers

  • 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.

    Tuesday, January 15, 2013 12:30 PM