NullReferenceException when adding list

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

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"

l_stList.stModule.Add(l_stModule)
End Sub
End Module


I don't understand how to solve this.




Responses

(No response found.)

Login to post response