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
Copy file name to clipboardExpand all lines: docs/csharp/language-reference/unsafe-code.md
+9-3Lines changed: 9 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -27,6 +27,8 @@ Unsafe code has the following properties:
27
27
- Using unsafe code introduces security and stability risks.
28
28
- The code that contains unsafe blocks must be compiled with the [**AllowUnsafeBlocks**](compiler-options/language.md#allowunsafeblocks) compiler option.
29
29
30
+
For information about best practices for unsafe code in C#, see [Unsafe code best practices](../../standard/unsafe-code/best-practices.md).
31
+
30
32
## Pointer types
31
33
32
34
In an unsafe context, a type can be a pointer type, in addition to a value type, or a reference type. A pointer type declaration takes one of the following forms:
@@ -148,8 +150,8 @@ internal struct Buffer
148
150
149
151
Fixed-size buffers differ from regular arrays in the following ways:
150
152
151
-
-May only be used in an `unsafe` context.
152
-
-May only be instance fields of structs.
153
+
-Can only be used in an `unsafe` context.
154
+
-Can only be instance fields of structs.
153
155
- They're always vectors, or one-dimensional arrays.
154
156
- The declaration should include the length, such as `fixed char id[8]`. You can't use `fixed char id[]`.
155
157
@@ -179,7 +181,7 @@ The preceding code illustrates several of the rules on the function accessed as
179
181
180
182
- Function pointers can only be declared in an `unsafe` context.
181
183
- Methods that take a `delegate*` (or return a `delegate*`) can only be called in an `unsafe` context.
182
-
- The `&` operator to obtain the address of a function is allowed only on `static` functions. (This rule applies to both member functions and local functions).
184
+
- The `&` operator to obtain the address of a function is allowed only on `static` functions. (This rule applies to both member functions and local functions.)
183
185
184
186
The syntax has parallels with declaring `delegate` types and using pointers. The `*` suffix on `delegate` indicates the declaration is a *function pointer*. The `&` when assigning a method group to a function pointer indicates the operation takes the address of the method.
185
187
@@ -192,3 +194,7 @@ You can learn more about function pointers in the [Function pointer](~/_csharpla
192
194
## C# language specification
193
195
194
196
For more information, see the [Unsafe code](~/_csharpstandard/standard/unsafe-code.md) chapter of the [C# language specification](~/_csharpstandard/standard/README.md).
197
+
198
+
## See also
199
+
200
+
-[Unsafe code best practices](../../standard/unsafe-code/best-practices.md)
0 commit comments