Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

c# use string in interpolation expression

string name = "Mark";
var date = DateTime.Now;

Console.WriteLine($"Hello, {name}! Today is {date.DayOfWeek}, it's {date:HH:mm} now.");
Console.WriteLine($"I have {2*2} apples");

// For ternary or "" add ()
Console.WriteLine($"I have a very cute {(true ? "cat": "dog")}");
Source by learn.microsoft.com #
 
PREVIOUS NEXT
Tagged: #string #interpolation #expression
ADD COMMENT
Topic
Name
1+2 =