Loading...
Gadget by Dot Net Spiders.

Monday, October 12, 2009

Dot Net Framework FAQ - Part Eight

How you deploy .NET assemblies?
One way is simply use xcopy. others are use and the setup projects in .net. and one more way is use of nontuch deployment.

What is Globalizationa and Localization ?
Globalization is the process of creating an application that meets the needs of users from multiple cultures. It includes using the correct
currency, date and time format, calendar, writing direction, sorting rules, and other issues. Accommodating these cultural differences in an application is called localization.Using classes of System.Globalization namespace, you can set application's current culture.
This can be achieved by using any of the following 3 approaches.
  1. Detect and redirect
  2. Run-time adjustment
  3. Using Satellite assemblies.

Whate are Resource Files ? How are they used in .NET?
Resource files are the files containing data that is logically deployed with an application.These files can contain data in a number of formats including strings, images and persisted objects. It has the main advantage of If we store data in these files then we don't need to compile these if the data get changed. In .NET we basically require them storing culture specific informations by localizing application's resources. You can deploy your resources using satellite assemblies.

Difference between Dispose and Finallize method?

Finalize method is used to free the memory used by some unmanaged resources like window handles (HWND). It's similar to the destructor syntax in C#. The GC calls this method when it founds no more references to the object. But, In some cases we may need release the memory used by the resources explicitely.To release the memory explicitly we need to implement the Dispose method of IDisposable interface.

What is encapsulation ?
Encapsulation is the ability to hide the internal workings of an object's behavior and its data. For instance, let's say you have a object named Bike and this object has a method named start(). When you create an instance of a Bike object and call its start() method you are not worried about what happens to accomplish this, you just want to make sure the state of the bike is changed to 'running' afterwards. This kind of behavior hiding is encapsulation and it makes programming much easier.

How can you prevent your class to be inherated further?
By setting Sealed - Key word
public sealed class Planet
{
//code goes here
}
class Moon:Planet
{
//Not allowed as base class is sealed
}

What is GUID and why we need to use it and in what condition? How this is created?
A GUID is a 128-bit integer (16 bytes) that can be used across all computers and networks wherever a unique identifier is required. Such an identifier has a very low probability of being duplicated. Visual Studio .NET IDE has a utility under the tools menu to generate GUIDs.

Why do you need to serialize.?
We need to serialize the object,if you want to pass object from one computer/application domain to another.Process of converting complex objects into stream of bytes that can be persisted or transported.Namespace for serialization is System.Runtime.Serialization.The ISerializable interface allows you to make any class Serializable..NET framework features 2 serializing method.
1.Binary Serialization 2.XML Serialization

What is inline schema, how does it works?
Schemas can be included inside of XML file is called Inline Schemas.This is useful when it is inconvenient to physically seprate the schema and the XML document.A schema is an XML document that defines the structure, constraints, data types, and relationships of the elements that constitute the data contained inside the XML document or in another XML document.Schema can be an external file which uses the XSD or XDR extension called external schema. Inline schema can take place even when validation is turned off.

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 an 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.

0 comments:

Post a Comment

RECENT POSTS

Related Posts with Thumbnails