公告
财富商城
积分规则
提问
发文
2019-02-23 09:16发布
来,给爷笑一个
For example implicitly
MyClass myClass = new MyClass(); int i = myClass;
This MSDN entry covers what you want exactly, should do the trick.
class MyClass { public static implicit operator int(MyClass myClass) { // code to convert from MyClass to int } }
Take a look there : implicit
You need to define this in the MyClass file.
MyClass
public static implicit operator int(MyClass instance) { if (instance == null) { return -1; } return instance._underlyingValue; }
最多设置5个标签!
This MSDN entry covers what you want exactly, should do the trick.
Take a look there : implicit
You need to define this in the
MyClass
file.