Example : C# 3.0 new features

 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;namespace Example.cSharp3Dot0
{
class Program
{

static void Main(string[] args)
{
List Languages = new List { “C#”, “VB”, “VC++” }; // —-> Collection Initializer

var languageQuery = //—-> Implicitly typed local variables
from one in Languages
where one == “VC++”
select new { one }; //—-> Anonymous types.
foreach (var name in languageQuery)
{
Console.WriteLine(“Its” + name.one);
Console.WriteLine(“Its” + name.one.ToString().getFirstTwoCharacters());
Console.ReadLine();
}
}
}

public static class myClass
{
public static string getFirstTwoCharacters(this System.String st) // —-> Extension methods
{
return st.Substring(0, 2);
}

}
}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: