@@ -39,7 +39,7 @@ unsafe_statement
39
39
40
40
> * Example* : In the following code
41
41
>
42
- > <!-- Example: {template:"standalone-lib", name:"UnsafeModifierOnStruct"} -->
42
+ > <!-- Example: {template:"standalone-lib-without-using ", name:"UnsafeModifierOnStruct"} -->
43
43
> ``` csharp
44
44
> public unsafe struct Node
45
45
> {
@@ -51,7 +51,7 @@ unsafe_statement
51
51
>
52
52
> the `unsafe ` modifier specified in the struct declaration causes the entire textual extent of the struct declaration to become an unsafe context. Thus, it is possible to declare the `Left` and `Right` fields to be of a pointer type. The example above could also be written
53
53
>
54
- > <!-- Example : {template :"standalone -lib ", name :"UnsafeContexts2 "} -->
54
+ > <!-- Example : {template :"standalone -lib - without - using ", name :"UnsafeContexts2 "} -->
55
55
> ```csharp
56
56
> public struct Node
57
57
> {
@@ -69,7 +69,7 @@ Other than establishing an unsafe context, thus permitting the use of pointer ty
69
69
70
70
> * Example * : In the following code
71
71
>
72
- > < ! -- Example : {template : " standalone-lib" , name : " UnsafeContexts3" , replaceEllipsis : true , ignoredWarnings : [" CS0168" ]} -- >
72
+ > < ! -- Example : {template : " standalone-lib-without-using " , name : " UnsafeContexts3" , replaceEllipsis : true , ignoredWarnings : [" CS0168" ]} -- >
73
73
> ```csharp
74
74
> public class A
75
75
> {
@@ -94,7 +94,7 @@ Other than establishing an unsafe context, thus permitting the use of pointer ty
94
94
>
95
95
> The situation is slightly different when a pointer type is part of the method’s signature
96
96
>
97
- > < ! -- Example : {template : " standalone-lib" , name : " UnsafeContexts4" , replaceEllipsis : true } -- >
97
+ > < ! -- Example : {template : " standalone-lib-without-using " , name : " UnsafeContexts4" , replaceEllipsis : true } -- >
98
98
> ```csharp
99
99
> public unsafe class A
100
100
> {
@@ -174,10 +174,8 @@ A *pointer_type* may be used as the type of a volatile field ([§14.5.4](classes
174
174
175
175
> * Note * : Although pointers can be passed as `ref ` or `out ` parameters , doing so can cause undefined behavior , since the pointer might well be set to point to a local variable that no longer exists when the called method returns , or the fixed object to which it used to point , is no longer fixed . For example :
176
176
>
177
- > < ! -- UndefinedExample : {template : " standalone-console" , name : " PointerTypes1" , replaceEllipsis : true , expectedOutput : [" *px1 = 10" ," *px2 = 20" ], expectedWarnings : [" x" ," x" ]} -- >
177
+ > < ! -- Undefined $ Example : {template : " standalone-console" , name : " PointerTypes1" , replaceEllipsis : true , expectedOutput : [" *px1 = 10" ," *px2 = 20" ], expectedWarnings : [" x" ," x" ]} -- >
178
178
> ```csharp
179
- > using System;
180
- >
181
179
> class Test
182
180
> {
183
181
> static int value = 20 ;
@@ -214,7 +212,7 @@ A method can return a value of some type, and that type can be a pointer.
214
212
215
213
> * Example * : When given a pointer to a contiguous sequence of `int `s , that sequence ’s element count , and some other `int ` value , the following method returns the address of that value in that sequence , if a match occurs ; otherwise it returns `null `:
216
214
>
217
- > < ! -- Example : {template : " standalone-console" , name : " PointerTypes2" , expectedWarnings : [" CS8321" ]} -- >
215
+ > < ! -- Example : {template : " standalone-console-without-using " , name : " PointerTypes2" , expectedWarnings : [" CS8321" ]} -- >
218
216
> ```csharp
219
217
> unsafe static int * Find (int * pi , int size , int value )
220
218
> {
@@ -288,7 +286,7 @@ When one pointer type is converted to another, if the resulting pointer is not c
288
286
289
287
> *Example *: Consider the following case in which a variable having one type is accessed via a pointer to a different type :
290
288
>
291
- > <!-- UndefinedExample : {template :"standalone -console ", name :"PointerConversions1 ", expectedWarnings :["CS8321"]} -->
289
+ > <!-- Undefined $ Example : {template :"standalone -console - without - using ", name :"PointerConversions1 ", expectedWarnings :["CS8321"]} -->
292
290
> ```csharp
293
291
> unsafe static void M ()
294
292
> {
@@ -307,9 +305,8 @@ When a pointer type is converted to a pointer to `byte`, the result points to th
307
305
308
306
> * Example * : The following method displays each of the eight bytes in a `double ` as a hexadecimal value :
309
307
>
310
- > < ! -- ImplementationDefinedExample : {template : " standalone-console" , name : " PointerConversions2" , expectedOutput : [" BA" ," FF" ," 51" ," A2" ," 90" ," 6C" ," 24" ," 45" ], expectedErrors : [" x" ," x" ]} -- >
308
+ > < ! -- ImplementationDefined $ Example : {template : " standalone-console" , name : " PointerConversions2" , expectedOutput : [" BA" ," FF" ," 51" ," A2" ," 90" ," 6C" ," 24" ," 45" ], expectedErrors : [" x" ," x" ]} -- >
311
309
> ```csharp
312
- > using System ;
313
310
> class Test
314
311
> {
315
312
> static void Main ()
@@ -420,9 +417,8 @@ A pointer member access of the form `P->I` is evaluated exactly as `(*P).I`. For
420
417
> * Example* : In the following code
421
418
>
422
419
> <!-- Example: {template:"standalone-console", name:"PointerMemberAccess1", expectedOutput:["(10,20)"]} -->
420
+ > <!-- Maintenance Note: A version of this type exists in additional-files as "PointStructWithToString.cs". As such, certain changes to this type definition might need to be reflected in that file, in which case, *all* examples using that file should be tested. -->
423
421
> ``` csharp
424
- > using System ;
425
- >
426
422
> struct Point
427
423
> {
428
424
> public int x ;
@@ -448,7 +444,7 @@ A pointer member access of the form `P->I` is evaluated exactly as `(*P).I`. For
448
444
>
449
445
> the `-> ` operator is used to access fields and invoke a method of a struct through a pointer . Because the operation `P ->I ` is precisely equivalent to `(* P ).I `, the `Main ` method could equally well have been written :
450
446
>
451
- > < ! -- IncompleteExample : {template : " standalone-console" , name : " PointerMemberAccess2" , expectedOutput : [" (10,20)" ]} -- >
447
+ > < ! -- Example : {template : " standalone-console" , name : " PointerMemberAccess2" , additionalFiles : [ " PointStructWithToString.cs " ] , expectedOutput : [" (10,20)" ]} -- >
452
448
> ```csharp
453
449
> class Test
454
450
> {
@@ -484,7 +480,7 @@ A pointer element access of the form `P[E]` is evaluated exactly as `*(P + E)`.
484
480
485
481
> * Example* : In the following code
486
482
>
487
- > <!-- Example: {template:"standalone-console", name:"PointerElementAccess1"} -->
483
+ > <!-- Example: {template:"standalone-console-without-using ", name:"PointerElementAccess1"} -->
488
484
> ``` csharp
489
485
> class Test
490
486
> {
@@ -504,7 +500,7 @@ A pointer element access of the form `P[E]` is evaluated exactly as `*(P + E)`.
504
500
>
505
501
> a pointer element access is used to initialize the character buffer in a `for ` loop . Because the operation `P [E ]` is precisely equivalent to `*(P + E )`, the example could equally well have been written :
506
502
>
507
- > < ! -- Example : {template : " standalone-console" , name : " PointerElementAccess2" } -- >
503
+ > < ! -- Example : {template : " standalone-console-without-using " , name : " PointerElementAccess2" } -- >
508
504
> ```csharp
509
505
> class Test
510
506
> {
@@ -548,8 +544,6 @@ The `&` operator does not require its argument to be definitely assigned, but fo
548
544
>
549
545
> <!-- Example: {template:"standalone-console", name:"Address-ofOperator", expectedOutput:["123"]} -->
550
546
> ``` csharp
551
- > using System ;
552
- >
553
547
> class Test
554
548
> {
555
549
> static void Main ()
@@ -618,7 +612,6 @@ Given two expressions, `P` and `Q`, of a pointer type `T*`, the expression `P
618
612
>
619
613
> <!-- Example: {template:"standalone-console", name:"PointerArithmetic", inferOutput:true} -->
620
614
> ``` csharp
621
- > using System ;
622
615
> class Test
623
616
> {
624
617
> static void Main ()
@@ -715,7 +708,7 @@ Fixed objects can cause fragmentation of the heap (because they can’t be moved
715
708
716
709
> * Example* : The example
717
710
>
718
- > <!-- Example: {template:"standalone-console", name:"FixedStatement1"} -->
711
+ > <!-- Example: {template:"standalone-console-without-using ", name:"FixedStatement1"} -->
719
712
> ``` csharp
720
713
> class Test
721
714
> {
@@ -756,8 +749,6 @@ Within a `fixed` statement that obtains a pointer `p` to an array instance `a`,
756
749
>
757
750
> <!-- Example: {template:"standalone-console", name:"FixedStatement2", inferOutput:true} -- >
758
751
> ```csharp
759
- > using System ;
760
- >
761
752
> class Test
762
753
> {
763
754
> static void Main ()
@@ -806,7 +797,7 @@ Within a `fixed` statement that obtains a pointer `p` to an array instance `a`,
806
797
807
798
> * Example * : In the following code
808
799
>
809
- > < ! -- Example : {template : " standalone-console" , name : " FixedStatement3" } -- >
800
+ > < ! -- Example : {template : " standalone-console-without-using " , name : " FixedStatement3" } -- >
810
801
> ```csharp
811
802
> class Test
812
803
> {
@@ -927,7 +918,7 @@ A fixed-size buffer declaration that declares multiple fixed-size buffers is equ
927
918
928
919
> * Example* :
929
920
>
930
- > <!-- Example: {template:"standalone-lib", name:"Fixed-sizeBuffers1"} -->
921
+ > <!-- Example: {template:"standalone-lib-without-using ", name:"Fixed-sizeBuffers1"} -->
931
922
> ``` csharp
932
923
> unsafe struct A
933
924
> {
@@ -937,7 +928,7 @@ A fixed-size buffer declaration that declares multiple fixed-size buffers is equ
937
928
>
938
929
> is equivalent to
939
930
>
940
- > <!-- Example : {template : " standalone-lib" , name : " Fixed-sizeBuffers2" } -- >
931
+ > <!-- Example : {template : " standalone-lib-without-using " , name : " Fixed-sizeBuffers2" } -- >
941
932
> ```csharp
942
933
> unsafe struct A
943
934
> {
@@ -968,7 +959,7 @@ The subsequent elements of the fixed-size buffer can be accessed using pointer o
968
959
969
960
> *Example *: The following declares and uses a struct with a fixed -size buffer member .
970
961
>
971
- > <!-- Example : {template :"standalone -console ", name :"Fixed -sizeBuffersInExpressions "} -->
962
+ > <!-- Example : {template :"standalone -console - without - using ", name :"Fixed -sizeBuffersInExpressions "} -->
972
963
> ```csharp
973
964
> unsafe struct Font
974
965
> {
@@ -1042,8 +1033,6 @@ All stack-allocated memory blocks created during the execution of a function mem
1042
1033
>
1043
1034
> <!-- Example: {template:"standalone-console", name:"StackAllocation", expectedOutput:["12345","-999"]} -->
1044
1035
> ``` csharp
1045
- > using System ;
1046
- >
1047
1036
> class Test
1048
1037
> {
1049
1038
> static string IntToString (int value )
0 commit comments