why I am getting following error for below code :-
Object reference not set to an instance of an object.
at InterviewTest.Form1.Button1_Click(Object sender, EventArgs e) in h:\visual studio 2010\Projects\InterviewTest\InterviewTest\Form1.vb:line 8
2.
3. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
4. Dim classOfService As New ClassOfService
5. Dim travelInformation As New TravelInformation
6.
7. classOfService.code = "GT"
8. travelInformation.classes.Add(classOfService)
9. classOfService.code = "HIK"
10. travelInformation.classes.Add(classOfService)
11. TextBox1.Text = travelInformation.classes(1).code
12. End Sub
13. End Class
14.
15. Public Class TravelInformation
16. Public Property classes As List(Of ClassOfService)
17. End Class
Tapan PatelPosted Sep 13, 2016, 5:39 PM
harry harishPosted Sep 13, 2016, 5:35 PM
Tapan PatelPosted Sep 13, 2016, 5:24 PM
Public Class TravelInformation
Public Property classes As List(Of ClassOfService) <-- List here states that it is a collection
End Class
harry harishPosted Sep 13, 2016, 5:18 PM
16. Public Property classes As List(Of ClassOfService)
Tapan PatelPosted Sep 13, 2016, 4:59 PM