Does "new IntPtr();" return a zero pointer ?

  • Thread starter Thread starter ORC
  • Start date Start date
O

ORC

When initializing a IntPtr can I then be sure that this initializes to a
zero pointer: ?
"IntPtr MyPointer = new IntPtr();"

Thanks
Ole
 
Yes, the default ctor will initialize the IntPtr to zero. There is
also:

IntPtr foo = IntPtr.Zero;
 
That would definitely give a zero IntPtr as its a value type. However, its probably clearer in the code to use IntPtr.Zero

Regards

Richard Blewett - DevelopMentor
http://staff.develop.com/richardb/weblog

When initializing a IntPtr can I then be sure that this initializes to a
zero pointer: ?
"IntPtr MyPointer = new IntPtr();"

Thanks
Ole
 
Back
Top