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 PatelRank #614 · 3.9K reputationPosted Sep 13, 2016, 1:39 PM EDT
Tapan PatelRank #614 · 3.9K reputationPosted Sep 13, 2016, 12:59 PM EDT
harry harish19 reputationPosted Sep 13, 2016, 1:18 PM EDT
16. Public Property classes As List(Of ClassOfService)
Tapan PatelRank #614 · 3.9K reputationPosted Sep 13, 2016, 1:24 PM EDT
Public Class TravelInformation
Public Property classes As List(Of ClassOfService) <-- List here states that it is a collection
End Class
harry harish19 reputationPosted Sep 13, 2016, 1:35 PM EDT