NullReferenceException when adding list

Posted by Ishan7 under C# on 2/11/2021 | Points: 10 | Views : 143 | Status : [Member] | Replies : 0

I am trying to add something to a list, but I get a System.NullReferenceException: 'Object reference not set to an instance of an object', this is my code:

Module Module1
Structure tList
Dim sgName As String
Dim sgTest As String
Dim stModule As List(Of tModule)
End Structure

Structure tModule
Public sgName As String
Public sgTest As String
End Structure
Sub Main()
Dim l_stModule As New tModule
Dim l_stList As New tList

l_stModule.sgName = "Module"
l_stModule.sgTest = "Test"

End Sub
End Module

I don't understand how to solve this.


(No response found.)

Login to post response