Cha*_*ion 13

您需要在MyClass文件中定义它.

public static implicit operator int(MyClass instance) 
{
    if (instance == null) 
    {
        return -1;
    }
    return instance._underlyingValue;
}
Run Code Online (Sandbox Code Playgroud)