Skip to main content


[share author='Nick Craver' profile='https://twitter.com/Nick_Craver' avatar='https://pbs.twimg.com/profile_images/623686606159872000/twD9NrLc_400x400.jpg' link='https://twitter.com/Nick_Craver/status/1561767524991115265' posted='2022-08-22 17:29:28']Protip: you can use nameof() in a format string in a constant since it doesn't change, example:

public const string ThisConstant = $"The name of this constant is {nameof(ThisConstant)}";

const string ThisConstant = $"The name of this constant is {nameof(ThisConstant)}"; void Main() {     Console.WriteLine(ThisConstant); }

twitter.com/daveaglick/status/…