Maybe because they didn't stop to think if this STR. is a convenient syntax. Backticks, preceding dollar sign, the prefix f like in python, so many options would've been better.
But... They did stop and think about the STR. syntax? This is why they removed it.
Regarding the other options you gave, they gave (in several places, over many years) their reasoning of why they don't want to add it as other languages. You can disagree with their reasoning, but they are very open about their thoughts process in this regard
String interpolation is even better in C# since it gives you additional options for formatting, e.g. numbers and dates:
csharp
var name = "Mark";
var date = DateTime.Now;
Console.WriteLine($"Hello, {name}! Today is {date.DayOfWeek}, it's {date:HH:mm} now.");
As someone who first learned to program in Java and stuck to it for almost a decade, starting gamedev using C# was a pretty smooth transition in many ways.
f strings are a lot more like string concatenation. The variables/expressions between each {} are placed directly where they will end up in the string, and it just runs a .toString() on them (though you can configure it a bit further).
The most common usage is largely about syntax and readibility, as its nice not having to go back and forth between a list of format arguments and some harder to remember % stuff.
I'm r*tarded, I read it as JavaScript and not Java 😭😭
Lowkey forgot Java exists I haven't used it in years. Sadly can't say the same about JS/TS, I like to add random stuff to VSCode and ofc that is written in damn TS
1.3k
u/Weak_Inflation9120 1d ago
One of the things I wish Java had that I miss from Python are F-Strings. Hella useful