People generally agree that C# and VB.net are more or less the exact same thing. But if you’ve developed in both, you’ll notice that VB.net is a lot more forgiving when it comes to type conversion.
For example take this
int someInt = 5;
string someString = "12345";
someString.Replace(someInt, "");
The above code will fail, but will work if replaced with:
int someInt = 5;
string someString = "12345";
someString.Replace(Convert.ToString(someInt), "");
Update
Better example:
Dim i As Integer = 1
Dim j As String = "1"
If i = j Then
MessageBox.Show("Bad comparison")
End If
VB.net is much more forgiving and does not require you to type cast all over the place.
So my question is: Is this explicit type casting going to still be required in future versions of C#, or will the compiler automatically be able to determine what types are required. And, does this mean VB.net is more advanced (because it already does this type conversion for you naturally), or does this mean VB.net is more prone to erroneous code or uses objects all over the place, behind the scenes?
Thanks in advance…
sorry but I just tried what you just said in vb.net with my default setting, it doesn’t work, I need to cast 5 to string too
default setting is;
option explicit on
option strict on
option infer on
I could live with infer off, but never with explicit or strict OFF. Never.
these 2, while off, gave a really bad name to vb/asp/vbs/etc. and you want that into C#?
edit
with your new example I get this error