Learning immediately: https://edu.csdn.net/course/play/20589/257758?utm_source=blogtoedu
Enumerated types and string type conversion
1. enumeration switch string, with .ToString ()
enum QQstate : short
{
Online = 1,
Offline,
Hidden = 5,
Leave,
Busy
}
QQstate state = QQstate.Online;
Console.WriteLine(state.ToString());
2. String transfer other types: Type target .Parse ()
string str = "123";
int myInt = int.Parse(str);
3. String enumeration with that Enum.Parse switch (), parameters need to pass a certain type, a type with typeof, then turn strong
enum QQstate : short
{
Online = 1,
Offline,
Hidden = 5,
Leave,
Busy
}
QQstate state1 =(QQstate) Enum.Parse(typeof(QQstate), "1");
Console.WriteLine(state1); // Online