How to provide conversion when using Reflection.SetValue?
问题 I have a class that pretends to be an int, so it has overloaded the various operators; public class MyId { int value; public virtual int Value { get { return this.value; } set { this.value = value; } } public MyId(int value) { this.value = value; } public static implicit operator MyId(int rhs) { return new MyId(rhs); } public static implicit operator int(MyId rhs) { return rhs.Value; } } However, when I use code like PropertyInfo.SetValue(myObj, 13, null) OR MyId myId = 13; int x = Convert