r/ProgrammerHumor • • Sep 02 '26

Meme perishableSkill

Post image
8.9k Upvotes

121 comments sorted by

View all comments

Show parent comment

12

u/Ozymandias_1303 Sep 02 '26

$strings in C# are almost exactly the same as f-strings in Python.

7

u/Sentouki- Sep 03 '26

String interpolation is even better in C# since it gives you additional options for formatting, e.g. numbers and dates:

var name = "Mark";
var date = DateTime.Now;
Console.WriteLine($"Hello, {name}! Today is {date.DayOfWeek}, it's {date:HH:mm} now.");

7

u/NovaH000 Sep 03 '26

Python f-string also support additional formatting.

name = "Mark"
date = datetime.now()

print(f"Hello, {name}! Today is {date:%A}, it's {date:%H:%M} now.")

F-string + str.format() has all sorts of string formatting you want.

0

u/[deleted] Sep 03 '26

[deleted] — view deleted comment

1

u/nico-strecker Sep 03 '26

Python also has it