[X]

Asp.Net 4.0 - Custom Output Caching Provider (Design Patterns in Action)

Desing Patterns in Action

Today we will develop a custom output caching provider in asp.net 4.0. In .net framework 4.0 microsoft has emphasized on provider model for pluggable development. The provider model in .net 4.0 has been used and promoted extensively.

Developers can write their custom provider for logging, membership, caching, viewstate without affecting the existing application and plug that up with just configuration changes.

I will try to show this by writing custom file based output caching for asp.net 4.0 application. There may be scenario where memory based caching is expensive, so we can make use of provider model and write our own custom output caching.

Let's start-

1. Create a C# Library Project

2. Add reference to System.Web dll

More...

C# - Swapping values of two variables without using third variable

 

 

Lots of guys are asked and have delved into solving a very common question - How do you swap values of two variables without using third variable?

Well there are more than one ways, we could achieve it.

So first let's start from school days.

1. using 3rd variable:

 

class Program
    {
        static void Main(string[] args)
        {
            SwappingUsingThirdVariable();
        }

        private static void SwappingUsingThirdVariable()
        {
            int num1=7, num2=9, num3=0;
            Console.WriteLine("Before swapping: num1={0}, num2={1}", num1, num2);
            num3 = num1; num1 = num2; num2 = num3;
            Console.WriteLine("After swapping: num1={0}, num2={1}", num1, num2);
            Console.ReadLine();
        }
    }

 

 


2. Witout using third variable and with help of plus/minus (+,-) operator: 

 

private static void SwappingUsingPlusMinusOperator()
        {
            int num1 = 7, num2 = 9;
            Console.WriteLine("Before swapping: 

num1={0}, num2={1}", num1, num2);
            if (num1 > num2)
            {
                num1 = num1 + num2;
                num2 = num1 - num2;
                num1 = num1 - num2;
                
            }
            else
            {
                num2 = num2 + num1;
                num1 = num2 - num1;
                num2 = num2 - num1;
                
            }
            Console.WriteLine("After swapping: 

num1={0}, num2={1}", num1, num2);
            Console.ReadLine();
        }

 

 

3. Witout using third variable and with help of mulitply/divide(*,/) operator:More...

Free SQL Server 2008 R2 Book download

SQL Server 2008 R2 - Free Book from Microsoft

If you are a sql server developer and wanted to have some free ebook on sql server 2008.

Here is the link I found while looking for the same. There is a free ebook download available on microsoft site for "SQL Server 2008 R2" edition.

This online book is the primary documentation for SQL Server.
Books Online includes the following types of information:
Setup and upgrade instructions.

Information about new features and backward compatibility.

Conceptual descriptions of the technologies and features in SQL Server.

Procedural topics describing how to use the various features in SQL Server.

Tutorials that guide you through common tasks.

More...

Posts By Month