C# unchecked keyword - dangerous?

  • Thread starter Thread starter Mark Bootfixer
  • Start date Start date
M

Mark Bootfixer

Guest
Hi,

Is there danger of memory corruption or leak if I use the unchecked keyword?

For example, if I have code that does this:

int x = int.MaxValue;
unchecked {
x = x + 10;
}

Is the worst case here that the value of x wraps and gives an unexpected value, or is there potentially more dangerous consequences that can arise from doing this?

Thanks

Mark

Continue reading...
 
Back
Top