Some Interesting Codes

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;


/// <summary>
/// Developer : Belbinson Toby
/// </summary>
namespace Class
{

public interface IEmployee
{
         void Result();
}

public interface IDeveloper
{
        void Result();
}

public class Employee
{
        public void Result()
       {
           Console.WriteLine("Employee");
       }
}


public class Developer : Employee, IEmployee, IDeveloper
{

              void IEmployee.Result()
              {
                     Console.WriteLine("IEmployee");
              }

             void IDeveloper.Result()
            {
                     Console.WriteLine("IDeveloper");
            }

            public new void Result()
           {
                   Console.WriteLine("Developer");
           }

}


public class Program
{
static void Main(string[] args)
{

Developer objDeveloper = new Developer();
objDeveloper.Result();// This will call Result Method in Developer Class

Employee objEmployee = new Developer();
objEmployee.Result();// This will call Result Method in Employee Class

IEmployee objIe = new Developer();
objIe.Result();// This will call Result Method in IEmployee Class

IDeveloper objId = new Developer();
objId.Result();// // This will call Result Method in IDeveloper Class

Console.ReadLine();

}
}
}

Extension Methods (C# Programming Guide)

http://msdn.microsoft.com/en-us/library/bb383977.aspx

Extension methods enable you to "add" methods to existing types without creating a new derived type, recompiling, or otherwise modifying the original type. Extension methods are a special kind of static method, but they are called as if they were instance methods on the extended type. For client code written in C# and Visual Basic, there is no apparent difference between calling an extension method and the methods that are actually defined in a type.




The most common extension methods are the LINQ standard query operators that add query functionality to the existing System.Collections.IEnumerable and System.Collections.Generic.IEnumerable<T> types. To use the standard query operators, first bring them into scope with a using System.Linq directive. Then any type that implements IEnumerable<T> appears to have instance methods such as GroupBy, OrderBy, Average, and so on. You can see these additional methods in IntelliSense statement completion when you type "dot" after an instance of an IEnumerable<T> type such as List<T> or Array.



The following example shows how to call the standard query operator OrderBy method on an array of integers. The expression in parentheses is a lambda expression. Many standard query operators take lambda expressions as parameters, but this is not a requirement for extension methods. For more information, see Lambda Expressions (C# Programming Guide).

Constraints on Type Parameters (C# Programming Guide)

http://msdn.microsoft.com/en-us/library/d5x73970(VS.80).aspx
When you define a generic class, you can apply restrictions to the kinds of types that client code can use for type arguments when it instantiates your class. If client code attempts to instantiate your class with a type that is not allowed by a constraint, the result is a compile-time error. These restrictions are called constraints. Constraints are specified using the where contextual keyword. The following table lists the six types of constraints:

Team Foundation Server...

Team Foundation Server...

Agile Scrum Methodology

Use .NET's BackgroundWorker to Keep ASP.NET Cache in Sync with a SQL Server Database

Introduction
Storing frequently accessed database data, like lookup lists, in ASP.NET’s cache is a great way to optimize a web application’s performance. But anytime you store database data in ASP.NET’s cache, you have to provide a way to update that cache. This ensures changes made in the database make it into the web application’s cache. This is handled using either notifications or polling.

Notifications are possible when using SQL Server 2005 with notification services and .NET’s SqlDependency object from the System.Data.SqlClient namespace. But notification services aren’t available in SQL Server 2008 or other databases. Even if you are using SQL Server 2005, employing this technology requires more server configuration and therefore complicates deployment.

Polling is often handled by setting an expiration of the cached item at some time interval such as hourly. That way the cache holds the data for an hour and then automatically dumps it. Then when the data is requested and the cache is empty, the data is read from the database and placed back into the cache. This approach works fairly well, but with two drawbacks. First, it requires the cache be refreshed even when it is not needed. Second, it runs on the same thread as the request so some unlucky user has to wait a little longer for their request to return while the data is read from the database and stored in the cache.

The BackgroundWorker object in .NET enables a better solution. When the web application starts, it spins off a background thread, and passes to it the application’s HttpContext object, enabling the thread, access to the application’s cache. When the web application ends, it stops the background thread. The background thread runs a continuous loop of sleeping for some time interval, and then polls the database to see if data has changed during that interval. If data has changed, the cache is refreshed. This solution is highly efficient because it runs on a background thread and refreshes the cache only when needed.