are there pointers in c# code example
Example 1: function pointers in C#
delegate int Func1(string s);
delegate Func1 Func2(Func1 f);
delegate*<string, int>;
delegate*<delegate*<string, int>, delegate*<string, int>>;
delegate* managed<string, int>;
delegate*<delegate* managed<string, int>, delegate*<string, int>>;
Example 2: function pointers in C#
unsafe class Example {
void Conversions() {
delegate*<int, int, int> p1 = ...;
delegate* managed<int, int, int> p2 = ...;
delegate* unmanaged<int, int, int> p3 = ...;
p1 = p2;
Console.WriteLine(p2 == p1);
p2 = p3;
}
}
Example 3: function pointers in C#
pointer_type
: ...
| funcptr_type
;
funcptr_type
: 'delegate' '*' calling_convention_specifier? '<' funcptr_parameter_list funcptr_return_type '>'
;
calling_convention_specifier
: 'managed'
| 'unmanaged' ('[' unmanaged_calling_convention ']')?
;
unmanaged_calling_convention
: 'Cdecl'
| 'Stdcall'
| 'Thiscall'
| 'Fastcall'
| identifier (',' identifier)*
;
funptr_parameter_list
: (funcptr_parameter ',')*
;
funcptr_parameter
: funcptr_parameter_modifier? type
;
funcptr_return_type
: funcptr_return_modifier? return_type
;
funcptr_parameter_modifier
: 'ref'
| 'out'
| 'in'
;
funcptr_return_modifier
: 'ref'
| 'ref readonly'
;