You have ever worked on C/C++, you will remember the term function pointer. It is a variable that stores the address of a function that can later be called through that function pointer.
delegate* syntax.unsafe class Example
{
void Example(Action<int> a, delegate*<int, void> f)
{
a(42);
f(42);
}
}
A delegate* type is a pointer type which means it has all of the capabilities and restrictions of a standard pointer type:
delegate* parameter or return type from an unsafe context.delegate* to void*.void* to delegate*.delegate* or any of its elements.delegate* parameter cannot be marked as paramsdelegate* type has all of the restrictions of a normal pointer type.Method groups will now be allowed as arguments to an address-of (&) operator. The type of such an expression will be a delegate* which has the equivalent signature of the target method and a managed calling convention.
It means developers can depend on overload resolution rules to work in conjunction with the address-of operator as shown below.
unsafe class Util
{
public static void Log()
{
Console.WriteLine("Log method without parameters.");
}
public static void Log(int val)
{
Console.WriteLine("Log method with 1 int parameter and the value is {0}.", val);
}
public static void Use()
{
delegate*<void> a1 = &Log; // Log()
delegate*<int, void> a2 = &Log; // Log(int val)
a1();
a2(4);
}
}