You cannot use string interpolation in that way: interpolated strings are a syntactic sugar for the older method using numbered parameters and are evaluated when thw interpolated string is constructed, not when it is used:
using System;
public class Program
{
static string name = "???";
static string xxx = $"Hello {name}!";
static string yyy = "Hello {0}!";
public static void Main()
{
name = "Paul";
Console.WriteLine($"Hello {name}!");
Console.WriteLine(xxx);
Console.WriteLine(yyy, name);
}
}
Will give you:
Hello Paul!
Hello ???!
Hello Paul!