S
Sam Sungshik Kong
Hello!
I studied C# a little bit and am trying to compare it with VB.Net.
There's 'Option Strict' in VB.Net.
I thought that if I turn it on, it is as strict as C# when checking types.
See the following codes.
<vb.net>
Option Strict On
Imports System
Module Main
Sub Main()
Dim S As Short = 0
S += 1 '*******Error!!! It should be S += 1S.
Console.WriteLine(S.ToString())
End Sub
End Module
</vb.net>
The above code generates an error because in the line of S+=1, 1 is integer
and S is Short.
In C#, the same code was compiled ok.
<csharp>
short s = 0;
s += 1; //okay
</csharp>
What is the rule for that?
An integer can be assigned to a short?
If so, VB.Net with 'Option Strict On' is more strict than C#.
What can I do to make C# compiler check very strictly?
Thanks in advance!
Sam
I studied C# a little bit and am trying to compare it with VB.Net.
There's 'Option Strict' in VB.Net.
I thought that if I turn it on, it is as strict as C# when checking types.
See the following codes.
<vb.net>
Option Strict On
Imports System
Module Main
Sub Main()
Dim S As Short = 0
S += 1 '*******Error!!! It should be S += 1S.
Console.WriteLine(S.ToString())
End Sub
End Module
</vb.net>
The above code generates an error because in the line of S+=1, 1 is integer
and S is Short.
In C#, the same code was compiled ok.
<csharp>
short s = 0;
s += 1; //okay
</csharp>
What is the rule for that?
An integer can be assigned to a short?
If so, VB.Net with 'Option Strict On' is more strict than C#.
What can I do to make C# compiler check very strictly?
Thanks in advance!
Sam