[英]Is there a benefit to overloading the explicit operator if implicit has been overloaded in C#?
[英]Question about implicit operator overloading in c#
MyClass c = 10;
有沒有辦法使這個代碼工作? 我知道通過隱式運算符重載你可以得到相反的工作:
int i = instanceOfMyClass;
謝謝
當然...
class MyClass
{
public static implicit operator MyClass(int value) { /* your code */ }
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.