Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Null reference for first memory address between 0 - 65535

I would like to understand a bit more about memory and I was unable to find it from Google, please forgive me if this is silly question.

How come the following code, accessing memory address 0(and up to 65535) in C# would throw NullReferenceException

byte* pointer = (byte*)0;

byte test = *pointer;

Thanks a lot in advance!

like image 393
Terry Avatar asked Aug 28 '26 06:08

Terry


1 Answers

This is a design feature of Windows itself. In order to catch programmer mistakes early in the development cycle, the virtual addresses from 0 to 64K (- 1) are invalid in all processes.

like image 159
Timores Avatar answered Aug 30 '26 21:08

Timores



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!