This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.
在寻找用户界定的操作者时,表述班应当更加准确?
sealed class Foo
{
// just the private static method!
private static int op_Implicit() { return 1; }
public static implicit operator int(Foo foo) { return 2; }
}
public class Program
{
private static void Main()
{
var param = Expression.Parameter(typeof(Foo), "x");
// IndexOutOfRangeException was unhandled!
var lambda = Expression.Lambda<Func<Foo, int>>(
Expression.Convert(param, typeof (int)), param);
}
}
还有可能界定静态的<代码>op_Explicit或op_Implicit
方法,其中不止一个论点和表述类别接受这一方法为用户界定的操作者!
p.s. expression 靠<代码>BledFlags.NonPublic旗帜的树木,可以搜索用户类型中的操作者,但该系统无法直接看到。 核心数字,但也允许信号标本找到“看像”用户定义的操作员的私人方法。 但是,C#规则不允许你界定和使用非公共经营者! 我认为,表达方式应当相同......。