AxibugEmuOnline/AxibugEmuOnline.Client/Assets/Script/AppMain/MsgBool.cs

50 lines
985 B
C#
Raw Normal View History

2024-12-11 21:21:27 +08:00
/// <summary>
/// String<6E><67>Bool<6F>ķ<EFBFBD><C4B7>Ϲ<EFBFBD>
/// </summary>
public struct MsgBool
{
public string ErrorMsg;
public bool Value;
2024-12-23 01:16:23 +08:00
//low C# readonly
//public override readonly string ToString()
public override string ToString()
2024-12-11 21:21:27 +08:00
{
if (Value)
{
return true.ToString();
}
else
{
return ErrorMsg;
}
}
public static implicit operator MsgBool(string errorMsg)
{
return new MsgBool { Value = false, ErrorMsg = errorMsg };
}
public static implicit operator MsgBool(bool value)
{
return new MsgBool { Value = value };
}
public static implicit operator bool(MsgBool msgBool)
{
return msgBool.Value;
}
2024-12-23 01:16:23 +08:00
//low C#
//public static implicit operator (bool, string)(MsgBool msgBool)
//{
// return (msgBool.Value, msgBool.ErrorMsg);
//}
2024-12-11 21:21:27 +08:00
2024-12-23 01:16:23 +08:00
public static implicit operator string(MsgBool msgBool)
2024-12-11 21:21:27 +08:00
{
return msgBool.ToString();
}
}