O'Reilly logo

C# for Java Developers by Adam Freeman, Allen Jones

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Unsafe Code

C#’s support for unsafe code is the language’s most significant divergence from Java. Unsafe code provides access to pointer data types and allows the programmer to work directly with the contents of memory. Unsafe features can be dangerous, are rarely needed, and should be avoided if possible. However, unsafe code is required when calling pre-.NET dynamic-link libraries (DLLs) that take pointers as arguments.

The unsafe Modifier

The unsafe features described in this section are available only within an unsafe context, declared using the unsafe modifier. The unsafe modifier is applicable to the declaration of classes, structs, interfaces, delegates, fields, methods, properties, events, indexers, operators, constructors, destructors, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required