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
  • 222
  • 6
  • 27

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
  • 224,436
  • 37
  • 411
  • 441
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
  • 5,854
  • 5
  • 29
  • 50