Is there any difference between the two statements:
IntPtr myPtr = new IntPtr(0); IntPtr myPtr2 = IntPtr.Zero;
I have seen many samples that use PInvoke that prefer the first syntax if the myPtr argument is sent by ref to the called function. If I’ll replace all new IntPtr(0) with IntPtr.Zero in my application, will it cause any damage?
IntPtris a value type, so unlikeString.Emptythere’s relatively little benefit in having the static propertyIntPtr.ZeroAs soon as you pass
IntPtr.Zeroanywhere you’ll get a copy, so for variable initialisation it makes no difference:There is one exception, and that’s comparison:
As a couple of posters have already said.