tags:

views:

45

answers:

2

Hi, After going through Marshall code snippet Got the Idea that marshalling is used to convert the Struct to Bytes and few other similar convesrions. But is this the only use of Marshall?

And while going through the MSDn sample I got the floowing line:

 // Initialize unmanged memory to hold the struct.
  IntPtr pnt = Marshal.AllocHGlobal(Marshal.SizeOf(p));

And also from few other sites I got the follwing lines like:

When you work with `unmanaged` code, you are `marshaling` data from your
`managed app-domain` to the `unmanaged` realm.

Now What is Manged and UnManaged domain or managed and unmanaged code. While writing my code How will I be able to distinguish what is Managed and What is unmanaged?

I just need to clear my fundamentals before going ahead, Any suggestion,doc or walkthrough as my sincere grattitude.

Thanks,
Subhen

A: 

managed = .NET (CLR common language runtime)

unmanaged = native

Use 'mixed mode' assemblies, programmed in C++/CLR, to bridge the two realms together.

GarethOwen
+1  A: 

Managed code is code that runs using the CLR (Common Language Runtime)...
Unmanaged code is code NOT dependent on the CLR, during runtime, such as a C program.

There is a wikipedia article for most of the Computer Science topics out there... Google is a friend of any developer.

ItzWarty
@ItzWarty, on my Code Snippet(from MSDN) it says // Initialize unmanged memory to hold the struct. IntPtr pnt = Marshal.AllocHGlobal(Marshal.SizeOf(p));Here it is initializng unmanaged memory IntPtr pnt, So does that mean IntPtr doesn't depend on CLR to run
Subhen
IntPtr = integer pointer struct. It is part of the CLR and it's full name is `System.IntPtr`. IntPtr is a value type that contains an integer which is of the environment operating system's address size... Ok i'm being extremely wordy, sorry.
ItzWarty