C# implicit cast “overloading” and reflection problem

前端 未结 2 1627
清歌不尽
清歌不尽 2021-01-21 07:50

I\'ve got a problem with the following code (which compiles but crashes):

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
u         


        
2条回答
  •  谎友^
    谎友^ (楼主)
    2021-01-21 08:45

    Convert.ChangeType() does not use implicit operators. You'll need to have your MyBoolean type implement IConvertible.

    The second problem is related. User-defined conversion operators are not used. You'd need to convert it manually before passing it to SetValue().

提交回复
热议问题