这是一些代码,每当我想到它时都会给我带来麻烦.
Option Strict On
Module Module1
Sub Main()
For Each i As Integer In New String() {"why", "is", "this", "tolerated?"}
' compiles just fine.
Next
End Sub
End Module
Run Code Online (Sandbox Code Playgroud)
C#根本不允许隐式地将字符串转换为整数.
class Program {
static void Main(string[] args) {
foreach (int i in new string[] {"that's", "better"}) {
// will not compile, and for good reason.
}
}
}
Run Code Online (Sandbox Code Playgroud)
为什么VB让我们这样做?我正试着玩这个,因为我在这里还比较新,但我也很好奇.我确信那里有开发人员的答案.