C# Implicit/Explicit Type Conversion

后端 未结 4 1923
夕颜
夕颜 2021-01-18 00:36

I have a simple scenario that may or may not be possible. I have a class that contains an integer, for this purpose I\'ll make it as simple as possible:

pub         


        
4条回答
  •  深忆病人
    2021-01-18 00:59

    Try something like this

        public static implicit operator int(Number num)
        {
            return num.Value;
        }
    

提交回复
热议问题