r/programmingmemes • u/Verpa11 • 13d ago
Since when did they add ragebait to C#, because WHAT IS THIS
18
8
3
u/recursion_is_love 13d ago
Weak as in weak-type. vs. Strong as in strong-type.
I better use dynamic type because I don't want to think before I write code.
11
u/gameplayer55055 13d ago
I still can't understand that.
You can't cast a char to the string
But 1+'1' will happily be compiled to 11 like in the js meme.
I think the truth is that char is 8 bit and string is 16 bits per character. And MS decided to not add implicit cast to avoid byte fuckery errors.
18
u/gameplayer55055 13d ago
UPD: I was wrong.
C# char is secretly ushort (16 bit too). BUT it is a value type while string is a reference type.
1+'1' will be compiled to 50, and 1+"1" is 11 because of some operator overload trickery.
3
2
2
-2
u/Hot-Employ-3399 13d ago
This is called a common sense. Char is not a string. Fuck auto conversion. MLs got it right not allowing even float <-> int implicit casting
1
134
u/vanteli 13d ago
char c = 'A'; string s = $"{c}";.ToString(); is for weak willed men and communists