what is string interpolation Ask Question
By   Junaid A     18-Nov-2024    1

$ - string interpolation

 

string name = "zahid"; 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, zahid! Today is Wednesday, it's 19:40 now.

Solutions


10125
Copyright Future Minutes © 2015- 2024 All Rights Reserved.   Terms of Service  |   Privacy Policy |  Contact US|  Pages|  Whats new?
Update on: Dec 20 2023 05:10 PM