1
HttpResponseMessage response = await client.PutAsJsonAsync($"api/products/{product.Id}", product);

In the above code I've been using the $ keyword but I don't the significance of this keyword. I searched in google but coiuldn't find proper answer. I think this might be a duplicate but couldn't find relative answer even in stackexchange.

Thanks in advance

ashveli
  • 248
  • 6
  • 28

2 Answers2

8

It's an interpolated string - the new feature of C# 6, which is basically just a syntax sugar for String.Format (compiler converts interpolated strings into the String.Format calls). Your string is equivalent to

String.Format("api/products/{0}", product.Id)
Sergey Berezovskiy
  • 232,247
  • 41
  • 429
  • 459
2
$"api/products/{product.Id}"

is the short version for

string.Format("api/products/{0}", product.Id);

You could have a look in the MSDN

Mighty Badaboom
  • 6,067
  • 5
  • 34
  • 51