C# 6.0 Support in Visual Studio 2012

Yes, you can install c# 6.0 into VS2012 and VS2013 on a per project basis as a NuGet package. You’ll have to install this package for every project that you want c# 6.0 features in. https://www.nuget.org/packages/Microsoft.Net.Compilers/ Installing Latest C# Compiler via Nuget Install-Package Microsoft.Net.Compilers EDIT: As pointed out in the comments below, upgrade your NuGet … Read more

Error CS1056: Unexpected character ‘$’ running the msbuild on a tfs continuous integration process

The problem can be fixed installing a Nuget package Microsoft.Net.Compilers. Below is the link of my highlighted answer: Project builds fine with Visual Studio but fails from the command line That feature is a syntactic sugar for C#6, try to install the latest version of the framework 4.6.2 https://www.microsoft.com/en-us/download/details.aspx?id=53345 Then go to your Project properties … Read more

What benefits does dictionary initializers add over collection initializers?

While you could initialize a dictionary with collection initializers, it’s quite cumbersome. Especially for something that’s supposed to be syntactic sugar. Dictionary initializers are much cleaner: var myDict = new Dictionary<int, string> { [1] = “Pankaj”, [2] = “Pankaj”, [3] = “Pankaj” }; More importantly these initializers aren’t just for dictionaries, they can be used … Read more

Formatting a string into columns using String Interpolation

You can use Alignment Component for this purpose. Like this: Console.WriteLine($”value: {d,-17} {s}”); The optional alignment component is a signed integer indicating the preferred formatted field width. If the value of alignment is less than the length of the formatted string, alignment is ignored and the length of the formatted string is used as the … Read more