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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top