Home
Blog
November 6, 2024

C# 11 - Numeric IntPtr

No items found.
No items found.
C# 11
C# 11

Let's list all the features that C# 11 brings to the table. Let's discuss them all one by one, with their use cases, and see how they can come in handy. At the bottom of each article, you can find a link to all 14 new C# features!

Numeric IntPtr

C# 11 brings an alias to IntPtr and UIntPtr. Those methods are used for some unsafe shenanigans, that this article is too short to define, but they are Pointers to memory. Or can be used as one.

IntPtr pointer = IntPtr.Zero;
UIntPtr uIntPtr = UIntPtr.Zero;

Those two can now be aliased by either nint or unint

nint pointer = nint.Zero;
unint uIntPtr = unint.Zero;

Those are alias and do not change how you use them, they can be now user exchangeable.

I do not know how I feel about this change. I think that IntPtr was clear and concise in its naming where nint is not. Also the n the letter at the start should suggest a pointer but it is not clear at first glance. I would probably still use IntPtr in my code where I can.

Further reading at dotnet GitHub page.

🢀 Prev
Improved method group

Current article:
Numeric IntPtr

Next 🡺
ref fields and ref scoped variable

Share this post

Let’s talk!

send the email
Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.
Write us

contact@vinode.io

call us

+48 692 223 170

address

05-420, Józefów, Tadeusza 22

I hereby consent to the transmission of my data, via this form, to contact@vinode.io, where it will be reviewed by authorized personnel. We are committed to providing a prompt response to your inquiry. In the event that this form has been submitted erroneously or you wish to retract your data, please communicate your request by sending an email to contact@vinode.io. Be assured that we uphold strict privacy standards and will neither disseminate your data to third parties nor inundate you with unsolicited correspondence.