DotNet FrameWork – Managed and Unmanaged Code – multicast delegates – Describe the difference between a Thread and a Process – Day 23 of 30

Describe the advantages of writing a managed code application instead of unmanaged one. What’s involved in certain piece of code being managed?

“Advantage includes automatic garbage collection,memory management,security,type checking,versioning

Managed code is compiled for the .NET run-time environment. It runs in the Common Language Runtime (CLR), which is the heart of the .NET Framework. The CLR provides services such as security,

memory management, and cross-language integration. Managed applications written to take advantage of the features of the CLR perform more efficiently and safely, and take better advantage of developers existing expertise in languages that support the .NET Framework.

Unmanaged code includes all code written before the .NET Framework was introduced—this includes code written to use COM, native Win32, and Visual Basic 6. Because it does not run inside the .NET environment, unmanaged code cannot make use of any .NET managed facilities.”

What are multicast delegates ? give me an example ?

Delegate that can have more than one element in its invocation List.

using System;

namespace SampleMultiCastDelegate

{

class MultiCast

{

public delegate string strMultiCast(string s);

}

}

MainClass defines the static methods having same signature as delegate.

using System;

namespace SampleMultiCastDelegate

{

public class MainClass

{

public MainClass()

{

}

public static string Jump(string s)

{

Console.WriteLine(“Jump”);

return String.Empty;

}

public static string Run(string s)

{

Console.WriteLine(“Run”);

return String.Empty;

}

public static string Walk(string s)

{

Console.WriteLine(“Walk”);

return String.Empty;

}

}

}

The Main class:

using System;

using System.Threading;

namespace SampleMultiCastDelegate

{

public class MainMultiCastDelegate

{

public static void Main()

{

MultiCast.strMultiCast  Run,Walk,Jump;

MultiCast.strMultiCast    myDelegate;

///here mydelegate used the Combine method of System.MulticastDelegate

///and the delegates combine

myDelegate=(MultiCast.strMultiCast)System.Delegate.Combine(Run,Walk);

}

}

}

Can a nested object be used in Serialization ?

Yes. If a class that is to be serialized contains references to objects of other classes, and if those classes have been marked as serializable, then their objects are serialized too.

Difference between int and int32 ?

Both are same. System.Int32 is a .NET class. Int is an alias name for System.Int32.

Describe the difference between a Thread and a Process?

A Process is an instance of a running application. And a thread is the Execution stream of the Process. A process can have multiple Thread.When a process starts a specific memory area is allocated to it. When there is multiple thread in a process, each thread gets a memory for storing the variables in it and plus they can access to the global variables which is common for all the thread. Eg.A Microsoft Word is a Application. When you open a word file,an instance of the Word starts and a process is allocated to this instance which has one thread.

What is the difference between an EXE and a DLL?

You can create an objects of Dll but not of the EXE.

Dll is an In-Process Component whereas EXE is an OUt-Process Component.

Exe is for single use whereas you can use Dll for multiple use.

Exe can be started as standalone where dll cannot be.

What is strong-typing versus weak-typing? Which is preferred? Why?

Strong typing implies that the types of variables involved in operations are associated to the variable, checked at compile-time, and require explicit conversion; weak typing implies that they are associated to the value, checked at run-time, and are implicitly converted as required. (Which is preferred is a disputable point, but I personally prefer strong typing because I like my errors to be found as soon as possible.)

Please read all the post in the Dotnet Framework series.

Reference : Dilip Kumar Jena ( https://mstechexplore.wordpress.com )

Advertisements

2 thoughts on “DotNet FrameWork – Managed and Unmanaged Code – multicast delegates – Describe the difference between a Thread and a Process – Day 23 of 30

  1. Pingback: DotNet FrameWork – Dot Net Basics Complete Series Reference – Day 0 of 30 « Exploring Dot Net with Dilip Kumar Jena

  2. Pingback: Introducción a C# « Programación C# (CSharp)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s