Multiple - Language Development in .NET Framework
.NET Framework encourages cross-language development using multiple programming languages. To become a .NET language, any language should have a compiler that translates the source code written in different languages into Microsoft Intermediate Language (MSIL).
MSIL code is called as Managed Code. Managed code runs in .NET environment.
In .Net framework the Common Runtime Language (CLR) contains a couple of just-in-time compilers (JIT) which can understand IL Code (managed Code), and can convert IL to native code (binary code targeted at a specific machine processor).
Hence any language with IL Code generating compiler can become a .Net language
Explain the delegates in C#.
Delegates in C# are objects which points towards a function which matches its signature. Delegates are reference type used to encapsulate a method with a specific signature. Delegates are similar to function pointers in C++; however, delegates are type-safe and secure.
Here are some features of delegates:
A delegate represents a class.
A delegate is type-safe.
We can use delegates both for static and instance methods
We can combine multiple delegates into a single delegate.
Delegates are often used in event-based programming, such as publish/subscribe.
We can use delegates in asynchronous-style programming.
We can define delegates inside or outside of classes.
Syntax of using delegates
//Declaring delegate
delegate void SampleDelegate(string message);
// declare method with same signature:
static void SampleDelegateMethod(string message) { Console.WriteLine(message); }
// create delegate object
SampleDelegate d1 = SampleDelegateMethod;
// Invoke method with delegate
d1("my program");
What is the purpose of connection pooling in ADO.NET?
Connection pooling enables an application to use a connection from a pool of connections that do not need to be re-established for each use. Once a connection has been created and placed in a connection pool, an application can reuse that connection without performing the complete connection creation process.
By default, the connection pool is created when the first connection with a unique connection string connects to the database. The pool is populated with connections up to the minimum pool size. Additional connections can be added until the pool reaches the maximum pool size.
When a user request a connection, it is returned from the pool rather than establishing new connection and, when a user releases a connection, it is returned to the pool rather than being released. But be sure than your connections use the same connection string each time. Here is the Syntax
conn.ConnectionString = "integrated Security=SSPI; SERVER=192.168.0.123; DATABASE=MY_DB; Min Pool Size=4;Max Pool Size=40;Connect Timeout=14;";
No comments:
Post a Comment