I have installed Visual Studio 2015 on a Virtual machine and it is GREAT..! I am making a post on it with screenshots but for now let me tell about some cool Visual C# 2015 preview features
1 Auto-Properties with initializers.
Now you can code something like
public int id { get; } = 15;
Yes this is coming. And setter is not a must while you implement though the property is still assignable at declaration time with a setter like the below
public int id { get; set; } = 17;
2 Say no to Console.WriteLine();
This is another cool thing, and a dream comes true for us all. Now you can
and this will never return and error and after this you can directly
WriteLine("This is awesome");
ReadLine();
This is not only for this but we can use any static classes in using and avoid their prefixes when we call their methods. Another good example is
and just call any method in the
Math
class which is static.
2.1 Can await
in the body of catch
/ finally
clause
private static async Task<string[]> ReturnSomeStringPlease()
{
try
{
using (var reader = File.OpenText("Words.txt"))
{
var s = await reader.ReadToEndAsync();
return s.Split(new[] { Environment.NewLine }, StringSplitOptions.None);
}
}
finally
{
using (var reader = File.OpenText("someotherWords.txt"))
{
var s = await reader.ReadToEndAsync();
//this has happened in my life time... yaaaaaayyy!!
return s.Split(new[] { Environment.NewLine }, StringSplitOptions.None);
}
}
}
There are even more things. I will write about them soon.
0 comments :