Menu ▼


SingleCall: They serve only one client request. Once the client request is over, they are subjected to garbage collection. They don't store any state information.
 
Singleton: They serve multiple clients, thereby allowing information sharing between requests. They are stateful objects unlike SingleCall, which is stateless.
 
There are used in the .NET REMOTING.
 
REMOTING works in homogenous environment, means both sides of the distributed application should be running under control CLR, i.e both the applications communicating should be .NET based.
__________________________________________________________________________________ 

Value Types Vs Reference Types

A data type is a value type if it holds the data within its own memory allocation. 

Value types include the following:

  • All numeric data types
  • Boolean, Char, and Date
  • All structures, even if their members are reference types
  • Enumerations

A reference type contains a pointer to another memory location that holds the data.

Reference types include the following:

  • String
  • All arrays, even if their elements are value types * Class types, such as Form
  • Delegates

_________________________________________________________________

Boxing Vs UnBoxing

Boxing is the process of converting a value type to the type object. Unboxing extracts the value type from the object  

(or)

Converting a value type to reference type is called Boxing.  Unboxing is the opposite operation.

Boxing is implicit; unboxing is explicit.

class Test

{

       static void Main() 

      {

            int i = 1;

            object o = i; // boxing

            int j = (int) o; // unboxing

      }

}

___________________________________________________________________________________
A class and an Interface are two different types (conceptually). Theoretically a class emphasis the idea of encapsulation, while an interface emphasis the idea of abstraction (by suppressing the details of the implementation). The two poses a clear separation from one to another. Therefore it is very difficult or rather impossible to have an effective meaningful comparison between the two.
 
____________________________________________________________________________________

Array: collection of similar data types. Array is reference type and hence it is stored in a Heap memory. Types of array are single dimensional, multi-dimensional and jagged Arrays (array of arrays).

A jagged array is an array whose elements are arrays

Declaring and initializing jagged array.  
int[][] jaggedArray = new int[5][];   
jaggedArray[0] = new int[3]; 
jaggedArray[1] = new int[5]; 
jaggedArray[2] = new int[2]; 
jaggedArray[3] = new int[8]; 
jaggedArray[4] = new int[10];
 

jaggedArray[0] = new int[] { 3, 5, 7, };

jaggedArray[1] = new int[] { 1, 0, 2, 4, 6 };

jaggedArray[2] = new int[] { 1, 6 };

jaggedArray[3] = new int[] { 1, 0, 2, 4, 6, 45, 67, 78 };

jaggedArray[4] = new int[] { 1, 0, 2, 4, 6, 34, 54, 67, 87, 78 };

_________________________________________________________________

Early Binding vs Late Binding

Binding refers the object type definition. 

Early binding allows developers to interact with the object’s properties and methods during coding. You can enjoy the benefits of intellisense. Early binding permits the compiler to check your code. Errors are caught at compile time. Early binding also results in faster code. It’s disadvantage is that you cannot create a generic object which may be bound to different types of objects. Method Overloading is implemented by early binding.

Late binding on the other hand permits defining generic objects which may be bound to different objects. Eg: you could declare myControl as Control without knowing which control you will encounter. You could then query the Controls collection and determine which control you are working on using the TypeOf method and branch to the section of your code that provides for that type. This is the only benefit of late binding. It’s disadvantages are that it is error prone and you will not enjoy much intellisense whils coding. Method Overriding is implemented by late binding.

_________________________________________________________________________

Memory Management: In .NET the memory management is done by the CLR. When the heap memory is exhausted the CLR calls the GC (Garbage collector).

The garbage collector's optimizing engine determines the best time to perform a collection based on the allocations being made. When the garbage collector performs a collection, it releases the memory for objects that are no longer being used by the application. It determines which objects are no longer being used by examining the application's roots. Every application has a set of roots. Each root either refers to an object on the managed heap or is set to null. An application's roots include global and static object pointers, local variables and reference object parameters on a thread's stack, and CPU registers. The garbage collector has access to the list of active roots that the just-in-time (JIT) compiler and the runtime maintain. Using this list, it examines an application's roots, and in the process creates a graph that contains all the objects that are reachable from the roots.

GC has 3 generations 0, 1 & 2 based on which the Garbage collector does the memory management of the heap.

 

Read More...
Submited By : Krishna Narra On 01 Dec 2013




Search dotnetlearners.com