This is a mirror of official site: http://jasper-net.blogspot.com/

Things you probably didn’t know about C#

| Sunday, February 28, 2010
I had some free time today, so I decided to learn something new in C#, here’s list of most interesting things that I learned:

1. Instead of

using (Font f1 = new Font(“Arial”, 10.0f))
{

using (Font f2 = new Font(“Calibri”, 10.0f))
{
//t use f1 and f2 here
}
}

it can be written:

using (Font f1 = new Font(“Arial”, 10.0f), Font f2 = new Font(“Calibri”, 10.0f))
{

//t use f1 and f2 here
}

2. Instead of

bool NameExists(string name)
{

return name == “dev” || name == “the” || name == “web” || name == “.net”;
}

it can be written:

bool NameExists(string name)
{

return new[] { “dev”, “the”, “web”, “.net” }.Contains(name);
}

Read more: DevtheWeb.NET's Blog

Posted via email from jasper22's posterous

0 comments: