I have the following bit of code:
public static string GetDomainRole(string role)
{
return $"{Startup.Configuration["Domain:Name"]}\\{role}";
}
Where
Startup.Configuration["Domain:Name"] = "MyDomain"
role = "SomeDomainRole"
And neither have anything other than a -> z, A -> Z, _
for their characters.
If I remove the first \
, then I get an error saying:
A '{' may only be escaped by doubling '{{' in an interpolated string
The problem is, my resultant string from GetDomainRole(...)
is:
MyDomain\\SomeDomainRole
With the double \\
. This obviously does not match my domain role MyDomain\SomeDomainRole
.
I'm sure I'm missing something really small here, but I can't for the life of me figure out how to get rid of the double \\
.
EDIT
Appears I just needed to adjust my search terms. This is a duplicate of How to use escape characters with string interpolation in C# 6?