PART I
C h a p t e r 2 0 :
U n s a f e C o d e , P o i n t e r s , N u l l a b l e T y p e s , a n d M i s c e l l a n e o u s T o p i c s
587
PART IPART I
int* p;
int q;
However, in C#, the
*
is
distributive and the declaration
int* p, q;
creates two pointer variables. Thus, in C# it is the same as these two declarations:
int* p;
int* q;
This is an important difference to keep in mind when porting C/C++ code to C#.
The * and & Pointer Operators
Two operators are used with pointers:
*
and
&
. The
&
is a unary operator that returns the
memory address of its operand. (Recall that a unary operator requires only one operand.)
For example,
int* ip;
int num = 10;
ip = #
puts into
Do'stlaringiz bilan baham: |