Nothing a řetězce v jazyce Visual Basic

Runtime Visual Basic a rozhraní .NET Framework hodnotí Nothing odlišně, pokud jde o řetězce.

Visual Basic Runtime a .NET Framework

Podívejte se na následující příklad:

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 obvykle vyhodnocuje Nothing jako prázdný řetězec (""). Rozhraní .NET Framework však nevyvolá výjimku při každém pokusu o provedení operace Nothings řetězcem .

Viz také