Konstanten Wenn const Werte Windows-API zu definieren, ist es besser, sie zu haben als constSo gruppieren Windows-API
public const int SW_HIDE = 0;
public const int SW_SHOWNORMAL = 1;
public const int SW_NORMAL = 1;
public const int SW_SHOWMINIMIZED = 2;
public const int SW_SHOWMAXIMIZED = 3;
public const int SW_MAXIMIZE = 3;
public const int SW_SHOWNOACTIVATE = 4;
public const int SW_SHOW = 5;
public const int SW_MINIMIZE = 6;
public const int SW_SHOWMINNOACTIVE = 7;
public const int SW_SHOWNA = 8;
public const int SW_RESTORE = 9;
public const int SW_SHOWDEFAULT = 10;
public const int SW_MAX = 10;
[DllImport("user32.dll")]
public static extern bool ShowWindow(HandleRef hWnd, int nCmdShow);
oder sie zusammen als eine Enumeration zu gruppieren.
public enum SW {
SW_HIDE = 0,
SW_SHOWNORMAL = 1,
SW_NORMAL = 1,
SW_SHOWMINIMIZED = 2,
SW_SHOWMAXIMIZED = 3,
SW_MAXIMIZE = 3,
SW_SHOWNOACTIVATE = 4,
SW_SHOW = 5,
SW_MINIMIZE = 6,
SW_SHOWMINNOACTIVE = 7,
SW_SHOWNA = 8,
SW_RESTORE = 9,
SW_SHOWDEFAULT = 10,
SW_MAX = 10
}
[DllImport("user32.dll")]
public static extern bool ShowWindow(HandleRef hWnd, SW nCmdShow);
Ich bevorzuge die 'Enum'-Version, die Sie gezeigt haben, aber ohne das redundante Präfix auf den Namen:' public enum SW {HIDE = 0, SHOWNORMAL = 1 ... etc.'. Zumindest, um [DRY] (https://en.wikipedia.org/wiki/Don't_repeat_yourself) zu beobachten und (die mögliche Existenz von) eine ganze Klasse von Fehlern oder Verwirrungen zu eliminieren ('SW.SX_MODE == ?? ? ') –