any way to use string interpolation in csharp code?

Dave Dai

CSharp string interpolation syntax:


string
name = "Mark"; var date = DateTime.Now; // Composite formatting: Console.WriteLine("Hello, {0}! Today is {1}, it's {2:HH:mm} now.", name, date.DayOfWeek, date); // String interpolation: Console.WriteLine($"Hello, {name}! Today is {date.DayOfWeek}, it's {date:HH:mm} now."); // Both calls produce the same output that is similar to: // Hello, Mark! Today is Wednesday, it's 19:40 now.

from https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/tokens/interpolated

this conflicts with Boyum's dynamic syntax:

$[$54.0.0]

 

As a result I've been using String.Format, which is less convenient than string interpolation.

 

So I want to ask if there is a way to use string interpolation at all?  

Comments

1 comment

  • Comment author
    Nadav Caridi

    Hi.
    I might be wrong but this might be due to c# version as well?
    Since string interpolation was first presented @ c# 10 (?).
    I know this does not answer your original question but I was wondering what c# version was actually running with the dynamic code.?

    0

Please sign in to leave a comment.