I want to call some method in curly brackets in a comment, for example like this:
$"{global::Company.Company.Helpers.Method()}_{Parameters.ProcessName}";
But in this situation everything behind the colon become a comment. Is there a way to use double colon in curly brackets in comment in C#?
This is likely due to the way that string formatting works -
{thing:A}will formatthingwith"A"as format information. For example, formatting an enum as{myEnumValue:D}will use the integer value, but{myEnumValue:G}will use the name of the enum value.You can work around this by wrapping the colon-containing expression in parentheses, like so: