Replies: 3 comments 1 reply
-
Moving to csharplang as this appears to be a request to change the language. |
Beta Was this translation helpful? Give feedback.
-
IntPtr is not a pointer. It is a pointer-bit integer (in the same way Int32 is a 32-bit integer). It's name actually comes from C/C++ where there is Because it is a pointer sized integer, it is sometimes used to hold or otherwise manipulate pointers, addresses, or related data. However, it is ultimately still an integer just as It would not be, IMO, good to allow a comparison to null here. Instead, you're likely better off using |
Beta Was this translation helpful? Give feedback.
-
2 "works", but does not actually do what you think it does. It does not compare against |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Testing an
IntPtr
fornull
requires comparing toIntPtr.Zero
. While this is OK, it could be simpler:Can this be made to work?
(2) actually works if you don't use C# strict mode (see dotnet/roslyn#18975). So it's not supposed to work and you're not supposed to do that. It would be nice if this was supported.
Beta Was this translation helpful? Give feedback.
All reactions