
- C# Basic Tutorial
- C# - Home
- C# - Overview
- C# - Environment
- C# - Program Structure
- C# - Basic Syntax
- C# - Data Types
- C# - Type Conversion
- C# - Variables
- C# - Constants
- C# - Operators
- C# - Decision Making
- C# - Loops
- C# - Encapsulation
- C# - Methods
- C# - Nullables
- C# - Arrays
- C# - Strings
- C# - Structure
- C# - Enums
- C# - Classes
- C# - Inheritance
- C# - Polymorphism
- C# - Operator Overloading
- C# - Interfaces
- C# - Namespaces
- C# - Preprocessor Directives
- C# - Regular Expressions
- C# - Exception Handling
- C# - File I/O
- C# Advanced Tutorial
- C# - Attributes
- C# - Reflection
- C# - Properties
- C# - Indexers
- C# - Delegates
- C# - Events
- C# - Collections
- C# - Generics
- C# - Anonymous Methods
- C# - Unsafe Codes
- C# - Multithreading
- C# Useful Resources
- C# - Questions and Answers
- C# - Quick Guide
- C# - Useful Resources
- C# - Discussion
What is unmanaged code in C#?
The following states what is an unmanaged code −
- Applications that are not under the control of the CLR are unmanaged
- The unsafe code or the unmanaged code is a code block that uses a pointer variable.
- The unsafe modifier allows pointer usage in unmanaged code.
Here is the module showing how to declare and use a pointer variable. We have used the unsafe modifier here.
Let us see the example −
Example
static unsafe void Main(string[] args) { int var = 20; int* p = &var; Console.WriteLine("Data is: {0} ", var); Console.WriteLine("Address is: {0}", (int)p); Console.ReadKey(); }
- Related Articles
- What is unsafe/unmanaged code in C#?
- Managed code vs Unmanaged code in C#
- Difference between Managed and Unmanaged code in .NET
- What is a managed code in C#?
- What is Polynomial Code?
- What is Gray code?\n
- What is Code Division Multiplexing?
- What is Intermediate Code Generation?
- What is Three Address Code?
- Difference between a Managed and an Unmanaged Switch
- Gray Code in C++
- What is Excess-3 Code?\n
- What is Remote Code Execution (RCE) ?
- Self Destructing Code in C
- Executing C# code in Linux

Advertisements