Ignoring the Class System
-
Hah! You guys are morons!Nothing in VB does not behave like null in C#.
I said there were differences.
Nothing plays the role of null in VB. There certainly are differences, some good and some bad.
-
Have you ever used c#?
string s = "In the year " + DateTime.Today.Year + ", Jaime was wrong!";
Console.WriteLine(s);Compiles and outputs "In the year 2015, Jaime was wrong!".
This is the only case where C# will implicitly convert from int to string. It's a special behavior built into the + operator, and not just a side-effect, it's actually in the spec. It's also completely inconsistent with the rest of the language, and stupid.
Anyways, it doesn't make the broad statement "C# allows implicit toString() for number types" true. Even worse, this was in a discussion about "VB and type safety don't work together", yet C#'s behavior - in this case - is much less type safe than VB.
-
From what I remember of C#, the String + operator actually does something like this:
string s = "In the year " + DateTime.Today.Year + ", Jaime was wrong!";
becomes
string s = new StringBuilder("In the year ").Append(DateTime.Today.Year).Append(", Jamie was wrong!").ToString();
-
It's more than that. The C# spec guarantees that it will ToString() anything that is on the left hand side of "+" if a string is on the right. It's not just a side effect of the compiler choosing to use StringBuilder.Append (or String.Concat), which both have a crapton of overloads.
-
Compiles and outputs "In the year 2015, Jaime was wrong!".
@Lorne_Kates said:
// adds Google Calendar appointment to come back here on January 1st, 2016, and make "ur wrong" joke.
ur wrong!
-
Did you set your appointment for the wrong day?
-