I cannot compile the following code
var baseUrl = $"http://{endPoint}/";
I got this code from a github project, and i guess the $-sign tells the compiler to use the value of the attribute(and even do methods that return a string).
I have been looking online, but i cant seem to find anything but @"String" to ignore escape characters.
The $
does string interpolation, which is a C# 6 feature.
It's the equivalent of doing this:
var baseUrl = string.Format("http://{0}/", endPoint);
You can read more about it here on MSDN.
If it does not compile for you, it's probably because you are using a version of Visual Studio that does not support C#6 features.
The $
string prefix is only available in C# 6. To change your targeted C# version in Visual Studio, go to your project properties → Build → Advanced... → Language Version, and select C# 6.0 .
Note that C# 6 is only supported in VS 2015 by default.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With