Stefan Ram
2017-04-24 08:03:16 UTC
I read a blog entry. It said something like:
»No. You can try all you want to, but /every/
expression is a allowed as an interpolation-expression.«.
I hit a "forbidden expression" on one of my first uses of
string interpolation.
public static class Program
{ public static void Main()
{ global::System.Console.WriteLine
( $"global::System.Math.PI = {global::System.Math.PI}." ); }}
Program.cs(4,35): error CS0103: The name 'global' does not exist in the current context
. The »:« might be interpreted as the begin of an
optional-colon-format. In fact, a work-around is:
public static class Program
{ public static void Main()
{ global::System.Console.WriteLine
( $"global::System.Math.PI = {(global::System.Math.PI)}." ); }}
global::System.Math.PI = 3.14159265358979.
»No. You can try all you want to, but /every/
expression is a allowed as an interpolation-expression.«.
I hit a "forbidden expression" on one of my first uses of
string interpolation.
public static class Program
{ public static void Main()
{ global::System.Console.WriteLine
( $"global::System.Math.PI = {global::System.Math.PI}." ); }}
Program.cs(4,35): error CS0103: The name 'global' does not exist in the current context
. The »:« might be interpreted as the begin of an
optional-colon-format. In fact, a work-around is:
public static class Program
{ public static void Main()
{ global::System.Console.WriteLine
( $"global::System.Math.PI = {(global::System.Math.PI)}." ); }}
global::System.Math.PI = 3.14159265358979.