---
title: "What is managed or unmanaged code?"  
description: "What is managed or unmanaged code?"  
author: "Shikhar Arora"  
published: 2019-12-07  
canonical: https://answers.mindstick.com/qa/92544/what-is-managed-or-unmanaged-code  
category: "technology"  
tags: ["software engineering", "programming language"]  
reading_time: 1 minute  

---

# What is managed or unmanaged code?

What is [managed](https://yourviews.mindstick.com/view/81745/how-china-managed-to-become-world-s-largest-navy) or unmanaged [code](https://yourviews.mindstick.com/view/85458/alan-turing-the-mastermind-behind-cracking-the-enigma-code-during-world-war-ii)

## Answers

### Answer by Shrikant Mishra

## Difference between Managed and Unmanaged code in .NET

The managed code is the code which is managed by the CLR(Common Language Runtime) in [**DotNet Framework**](https://answers.mindstick.com/qa/92545/what-is-dot-net). Whereas the Unmanaged code is the code which is directly executed by the operating system. Here the below are some important differences between the Managed code and Unmanaged code:

![What is managed or unmanaged code?](https://answers.mindstick.com/questionanswer/b5a4e91e-8ac8-49bc-a211-513f6f5eb3f1/images/2f9ecf1a-c79c-4eeb-901a-73e204e1885a.jpeg)

### 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();
}
```


---

Original Source: https://answers.mindstick.com/qa/92544/what-is-managed-or-unmanaged-code

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
