Parameter parameter without parameter Parameter type In C #

I am trying to use a trial version of a third-party software written in C #. While I try to use its API, I am facing a strange problem.

I am using visual studio 2015 and I found an interesting extended method signature in my API SDK

public static class CallExtendedInfoEx { public static void AddToSIPMessage(this CallExtendedInfo info, msg); } 

The second type of parameter does not exist . It has never been seen in C #. I am trying to give the general parameter Object as the second parameter, and C # Compiler gives a weird error

Severity Code Description Project File Line

Error CS1503 Argument 2: Cannot convert from 'object' to '.'

It works with "null" ... No compiler error or runtime error [ignored, I think]

How can these guys write such code in C #? Is it possible? Any idea?

Note. I suspect the problem is with code shading ... But still, I don’t understand what is going on here.

  IL_0073: call void [CallExtendedInfoEx::AddToSIPMessage(class [VoIP.CallExtendedInfo, class [VoIPSDK]''.'') 
+7
source share
2 answers

Well, looking at the output of ILDASM, it is pretty obvious that the argument is of a valid type. Of course, this is a type that cannot be called in C #, but it is great for the CLR in general.

The fact that you can pass null should not be surprising - the argument is a reference type (or convertible from null ), so null is an absolutely valid value. On the other hand, the expectation of passing an instance of object completely wrong - you can only pass more derived types as an argument, not less. It's nice to pass string (more specific) instead of object (less specific), but not vice versa.

Most likely, this is either a method that you should not relate to (i.e., not part of the public API / SDK contract), or you expect to get instances of the argument from some other method - never using an explicit type anywhere.

+5
source share

This is invalid C # code. Some decompiler probably gave you this code, or the documentation in which you copied it due to a malfunction.

+3
source share

All Articles