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 ofusing (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
0 comments:
Post a Comment