次のコードで型変換に問題があります。
public class pr<T>
{
private T tt;
public pr( T value ) {
this.tt = value;
}
public static explicit operator T(pr<T> op)
{
return default(T);
}
public static explicit operator pr<T> (T op)
{
return null;
}
}
使用法:
byte value = 255;
pr<byte> property = new pr<byte>(50);
property = (pr<byte>)value; // no error here, works well test it throught debugger.
value = (pr<byte>)property; // An explicit conversion exists are u missing cast?
私が間違っていることを教えてください。私はただの初心者で、rly は私が何をすべきか理解していません。私の悪い英語をお詫びします。ありがとうございました。PS の暗黙的な変換は正常に機能します。