Visual Basic en tiempo de ejecución y .NET Framework evalúan de manera diferente Nothing cuando se trata de cadenas.
Visual Basic Runtime y .NET Framework
Considere el ejemplo siguiente:
Visual Basic
Dim MyString As String = "This is my string" Dim stringLength As Integer ' Explicitly set the string to Nothing. MyString = Nothing ' stringLength = 0 stringLength = Len(MyString) ' This line, however, causes an exception to be thrown. stringLength = MyString.Length
Visual Basic Runtime normalmente evalúa Nothing como una cadena vacía (""). Sin embargo, .NET Framework no lo hace, y se producirá una excepción cuando se intente realizar una operación de cadena en Nothing.
No hay comentarios:
Publicar un comentario