I'm working on a project and they gave me a C# file with code similar to what I had to do. Investigating it I found this:
valorOpcion1 = "valor_que_viene_de_un_lado";
valorOpcion2 = "valor_que_viene_de_otro_lado";
var miLista = new List<string>
{
$"opcion1:{valorOpcion1}",
$"opcion1:{valorOpcion2}"
};
What it does is define and initialize a list of strings with two default values. My doubt comes with the $
one with those chains, I don't know what it is.
What does putting the dollar sign ( $
) in front of a string do? Is there a difference between, say, "hola"
and $"hola"
?