다음을 통해 공유


Visual Basic의 Nothing 및 문자열

Visual Basic 런타임과 .NET Framework에서는 Nothing이 문자열에 있는 경우 이를 서로 다르게 평가합니다.

Visual Basic 런타임 및 .NET Framework

다음 예제를 참조하십시오.

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 런타임에서는 일반적으로 Nothing을 빈 문자열("")로 평가합니다. 그러나 .NET Framework에서는 Nothing을 빈 문자열로 평가하지 않으므로 Nothing에 대해 문자열 연산을 수행할 때마다 예외가 throw됩니다.

참고 항목

기타 리소스

Visual Basic의 문자열 소개