You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The \* or -> operator must be applied to a pointer
13
+
The \* or -> operator must be applied to a data pointer
14
14
15
-
The \* or -> operator was used with a nonpointer type. For more information, see [Pointer types](../language-reference/unsafe-code.md#pointer-types).
15
+
The \* or -> operator was used with a nonpointer type or with a function pointer. Function pointers cannot be dereferenced in C#. For more information, see [Pointer types](../language-reference/unsafe-code.md#pointer-types) and [Function pointers](../language-reference/unsafe-code.md#function-pointers).
16
16
17
17
The following sample generates CS0193:
18
18
@@ -45,3 +45,19 @@ public class MyClass
45
45
}
46
46
}
47
47
```
48
+
49
+
The following example shows that function pointers cannot be dereferenced in C#, unlike in C/C++:
50
+
51
+
```csharp
52
+
unsafeclassFunctionPointerExample
53
+
{
54
+
publicstaticvoidLog() { /* ... */ }
55
+
56
+
publicstaticunsafevoidExample()
57
+
{
58
+
delegate*<void> fp = &Log; // pointer to managed function Log()
59
+
fp(); // OK; call Log() via function pointer
60
+
(*fp)(); // Error; CS0193, function pointers cannot be dereferenced
0 commit comments