C Sharp Programming/Keywords/unsafe
From Wikibooks, the open-content textbooks collection
The unsafe keyword may be used to modify a procedure or define a block of code which uses unsafe code. Code is unsafe if it uses the "address of" operator(&) or if it uses a pointer operator (*).
In order for the compiler to compile code containing this keyword, you must use the /unsafe option when using the Microsoft C-Sharp Compiler.
// example of unsafe to modify a procedure class MyClass { unsafe static void(string *msg) { Console.WriteLine(*msg) } } // example of unsafe to modify a code block string s = "hello"; unsafe { char *cp = &s[2]; *cp = 'a'; }
| C# Keywords | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Special C# Identifiers | ||||||||||
|