Showing posts with label .Net. Show all posts
Showing posts with label .Net. Show all posts

Monday, July 2, 2012

How to force garbage collector to run


Is this possible to force garbage collector to run? 


Yes, we can force garbage collector to run using following code.
System.GC.Collect().

Role of .Net data provider


What is the role of data provider?


The .NET data provider layer resides between the application and the database. Its task is to take care of all their interactions. The .NET Data provider can be demonstrated to be:
SQL Server data provider 
OLEDB data provider 
ODBC Data Provider


ADO.NET supports the following OLE DB Providers:
- SQLOLEDB - Microsoft OLE DB Provider for SQL Server.
- MSDAORA - Microsoft OLE DB Provider for Oracle.
- Microsoft.Jet.OLEDB.4.0 - OLE DB Provider for Microsoft Jet.

Compilation and Execution of .Net application


Describe how a .Net application is compiled and executed?


From the source code, the compiler generates Microsoft Intermediate Language (MSIL) which is further used for the creation of an EXE or DLL. The CLR processes these at runtime. Thus, compiling is the process of generating this MSIL. The way you do it in .Net is as follows:
Right-click and select Build / Ctrl-Shift-B / Build menu, Build command
F5 - compile and run the application. 
Ctrl+F5 - compile and run the application without debugging.


Compilation can be done with Debug or Release configuration. The difference between these two is that in the debug configuration, only an assembly is generated without optimization. However, in release complete optimization is performed without debug symbols.

Event and Delegate


What is an Event?


When an action is performed, this action is noticed by the computer application based on which the output is displayed. These actions are called events. Examples of events are pressing of the keys on the keyboard, clicking of the mouse. Likewise, there are a number of events which capture your actions.


Delegate :


Delegates are kind of similar to the function pointers. But they are secure and type-safe. A delegate instance encapsulates a static or an instance method. Declaring a delegate defines a reference type which can be used to encapsulate a method having a specific signature.


Language Integrated Query ( LINQ )


What is Language Integrated Query (LINQ)? 


LINQ is a set of extensions to .NET Framework that encapsulate language integrated query, set and other transformation operations. It extends VB, C# with their language syntax for queries. It also provides class libraries which allow a developer to take advantages of these features.

.NET Mobile overview

.NET Mobile overview


.NET Mobile is a platform for developing applications for mobile phones. It’s an extension to .NET Framework and is called Microsoft Mobile Internet Toolkit. It is a set of server side forms controls. These controls produce different output formats i.e. WML, HTML or even compact HTML. This allows developers to create an application using a single paradigm instead of developing an application multiple times using different paradigms based on what different mobiles support. The advantage is standardization, less redundancy, and Microsoft support.

Handle Exceptions in .NET 2.0


Explain how to Handle Exceptions in .NET 2.0.


There are different methods for handling the exceptions. For example


Method 1 :


try
{
     // code here
}
catch(Exceptiontype *etype_object)
{
     // code here.
}


Method 2 :
try
{
       // code
}
catch(Exceptiontype *etype_object)
{
        throw new Custom_Exception();
}

Difference between object pooling and connection pooling


How does object pooling and connection pooling differ?


In Object pooling, you can control the number of connections. In connection pooling, you can control the maximum number reached.


When using connection pooling, if there is nothing in the pool, a connection is created since the creation is on the same thread.


In object pooling, the pool decides the creation of an object depending on whether the maximum is reached which in case if it is, the next available object is returned. However, this could increase the time complexity if the object is heavy.

Sunday, July 1, 2012

Object Pooling in .NET


What is an object pool in .NET?


An object pool is a container of objects that holds a list of other objects that are ready to be used. It keeps track of following:
Objects that are currently in use
The number of objects the pool holds
Whether this number should be increased
The request for the creation of an object is served by allocating an object from the pool.


This reduces the overhead of creating and re-creating objects each time an object creation is required.

Why is an Object Pool required

Why is an Object Pool required?


To enhance performance and reduce the load of creating new objects, instead re using existing objects stored in memory pool. 
Object Pool is a container of objects that are for use and have already been created. Whenever an object creation request occurs, the pool manager serves the request by allocating an object from the pool. This minimizes the memory consumption and system's resources by recycling and re-using objects. 
When the task of an object is done, it is sent to the pool rather than being destroyed. This reduces the work for garbage collector and fewer memory allocations occur.

GetCommandLineArgs() method in C# .NET


What is the use of GetCommandLineArgs() method in C#.NET?


With GetCommandLineArgs() method, the command line arguments can be accessed. 
The value returned is an array of strings.

Compare C# .NET Generics and C++ Templates


How does C#.NET Generics and C++ Templates compare?


C# generics and templates in C++ are more or less similar syntactically.


C# Generic types are strong typed. C++ Templates are loosely typed.
C# Generic types are instantiated at the runtime. C++ templates are instantiated at the compile time.
C# Generic types do not permit the type parameters to have default values. C++ templates do.

Achieve polymorphism in C# .NET


How to achieve polymorphism in C#.NET?


Polymorphism is when a class can be used as more than one type through inheritance. It can be used as its own type, any base types, or any interface type if it implements interfaces.It can be achieved in the following ways.


Derived class inherits from a base class and it gains all the methods, fields, properties and events of the base class.


To completely take over a class member from a base class, the base class has to declare that member as virtual.

const and readonly in C# .NET


What is the difference between const and readonly in C#.NET?


The read only can be modified by the class it is contained in. However, the const cannot be modified. It needs to be instantiated only at the compile time.