Advertisement
Guest User

Untitled

a guest
Sep 23rd, 2014
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. Public Class PrivateFieldNullTest
  2.  
  3. Public Sub NullTestClass()
  4. _testClass = Nothing
  5. End Sub
  6.  
  7. Private _testClass As TestClass
  8. Public Property GetTestClass() As TestClass
  9. Get
  10. If _testClass Is Nothing Then
  11. _testClass = New TestClass()
  12. _testClass.TestString = GetRandomString(5)
  13. End If
  14.  
  15. Return _testClass
  16. End Get
  17.  
  18. Set(value As TestClass)
  19. _testClass = value
  20. End Set
  21. End Property
  22. End Class
  23.  
  24. Public Class TestClass
  25. Public Property TestString() As String
  26. End Class
  27.  
  28. Private Sub NullTest()
  29.  
  30. Dim toc As New PrivateFieldNullTest()
  31.  
  32. Dim tc = toc.GetTestClass
  33.  
  34. CheckIsSame.Text &= String.Format("NullTest - Before nullify '{0}';", tc.TestString)
  35.  
  36. toc.NullTestClass()
  37.  
  38. CheckIsSame.Text &= String.Format(" After nullify '{0}';", tc.TestString)
  39. CheckIsSame.Text &= String.Format(" new test string after Nullify '{0}';", toc.GetTestClass.TestString)
  40. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement