C # Will "WindowState.ToString" change between cultures

Take the following code for example:

    if (Convert.ToString(frm.WindowState) == "Minimized")
        Layout.WindowState = "Maximized";
    else
        Layout.WindowState = Convert.ToString(frm.WindowState);

      

We are analyzing the definition of the window status bar i.e. "Minimized".

Will this string description change between cultures?

Finally, while this code has an Enum that we could use to check the state of the window?

Can we refactor this code segment?

+1


source to share


3 answers


The value WindowState

is an enumeration - System.Windows.Forms.FormWindowState

. Just compare to enum constants, skip the madness ToString()

.



+8


source


It shouldn't change culturally as it just turns the Enum name into a string. The Enum name does not change when you use a different .Net / Windows / IDE culture, so it stays as it was originally written.



+1


source


WindowState is an enum.

I suggest using a good IDE (Visual Studio fe) to make details like this obvious.

System.Windows.WindowState

0


source







All Articles