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

50 lines
1.0 KiB
C#
Raw Normal View History

2025-01-07 14:21:22 +08:00
/// <summary>
/// String和Bool的缝合怪
2024-12-11 21:21:27 +08:00
/// </summary>
public struct MsgBool
{
public string ErrorMsg;
2025-01-07 14:21:22 +08:00
public bool Value;
//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;
2025-01-07 14:21:22 +08:00
}
//low C#
//public static implicit operator (bool, string)(MsgBool msgBool)
//{
// return (msgBool.Value, msgBool.ErrorMsg);
//}
public static implicit operator string(MsgBool msgBool)
2024-12-11 21:21:27 +08:00
{
return msgBool.ToString();
}
}