private static Func<KeyValuePair<double, PrintLevelDetails>, double> func_0; ... func_0 = new Func<KeyValuePair<double, PrintLevelDetails>, double>(null, (IntPtr) smethod_0); ... private static double smethod_0(KeyValuePair<double, PrintLevelDetails> keyValuePair_0) { return keyValuePair_0.Key; } 

Error in decompiled code:

CS0428 Cannot convert method group 'smethod_0' to non-delegate type 'System.IntPtr'. Did you intend to invoke the method?

  • And what is the question? The decompiler decompiled something that is not (completely) correct. - VladD
  • The question is how to fix? - jshapen

2 answers 2

When you create a delegate in IL, its constructor is usually used, taking a pair of arguments (object, IntPtr) - an object and a pointer to its method.

In C # code, you should instead use the form object.Method (in the case of a static method, instead of object you can write a class or write nothing if it is a method of the current class):

 func_0 = smethod_0 

or

 func_0 = НеВашКласс.smethod_0 

    Your decompiler was wrong.

    Try to do it manually:

     func_0 = kvp => kvp.Key;