English 中文(简体)
这难道是一种言语吗? #3 [闭门]
原标题:Is this is an ExpressionTrees bug? #3 [closed]

在寻找用户界定的操作者时,表述班应当更加准确?

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#规则不允许你界定和使用非公共经营者! 我认为,表达方式应当相同......。

问题回答

暂无回答




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签