Wednesday, February 27, 2008

Unsafe Keyword

Today I was looking at the source code of Jon Skeet's blog post: Visualising the Mandelbrot set with LINQ - yet again. What interested me (out of all things) is a block of code with the keyword Unsafe.

I never used Pointers in C# and therefore had no clue that you needed to use the Unsafe keyword block around anything that had "unsafe code", which included Pointers in his case.

image

This is another good example of why looking at source code is so important, even when its not your own or of immediate work importance. You never know what you will learn.

For more interesting source code I would recommend Scott Hanselman's Code Series on his blog, that can be found by clicking here.

For more information on Unsafe keyword, check out this MSDN page: http://msdn2.microsoft.com/en-us/library/t2yzs44b.aspx

0 comments: