문제

MyClass c = 10;

Is there any way to make this code work? I know that through the implicit operator overloading you can get the opposite to work:

int i = instanceOfMyClass;

Thanks

도움이 되었습니까?

해결책

Sure...

class MyClass
{
    public static implicit operator MyClass(int value) { /* your code */ }
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top