Measure time for code execution

void Main()
{
    int startTick = Environment.TickCount;
    Thread.Sleep(1000);
    int endTick = Environment.TickCount;

    Console.WriteLine("Thread slept for {0} ms",    (endTick - startTick));
}

Lambda Expressions Sample

  using System;

//A lambda expression is an anonymous function that can contain expressions and statements,
//and can be used to create delegates or expression tree types.

//All lambda expressions use the lambda operator =>, which is read as "goes to".
//The left side of the lambda operator specifies the input parameters
//(if any) and the right side holds the expression or statement block.

//The lambda expression x => x * x is read "x goes to x times x."

//This expression can be assigned to a delegate type.

delegate string NoInputStrOutputDel ();
delegate int IntInputIntOutputDel ( int i );
delegate string MultiStrInputStrOutputDel ( string salutation , string firstName , string lastName );

public class MyClass
{
public static void Main ()
{

NoInputStrOutputDel del1 = () => "Output without Input";
Console.WriteLine ( del1 () );

IntInputIntOutputDel del2 = x => x * x;
Console.WriteLine ( del2 ( 5 ) );

MultiStrInputStrOutputDel del3 = ( i , j , k ) => "Hello " + i + " " + j + " " + k;
Console.WriteLine ( del3 ( "Mr." , "Ajit" , "Singh" ) );

Console.ReadKey ();

}
}