1

I have a property defined as a list of integers:

Public Property lista_consultas_registros_cambio_clasificacion() As List(Of String)
        Get
            Return insideQueries_representaciones_clasificacion_diferente
        End Get
        Set(value As List(Of String))
            insideQueries_representaciones_clasificacion_diferente = value
        End Set
    End Property

I tried to add an item using:

Catalogo_Rep.lista_consultas_registros_cambio_clasificacion.Add("Text")

and i get the following error:

System.NullReferenceException:object reference not set to an instance of an object

OneFineDay
  • 8,789
  • 3
  • 22
  • 34
Georgy boy
  • 25
  • 10

1 Answers1

1

Your internal field insideQueries_representaciones_clasificacion_diferente has not been initialized.

You need to initialize it in the constructor.

insideQueries_representaciones_clasificacion_diferente = new List(of String)

Technically you don't need to initialize it in the constructor as long as it is initialized before use. But generally when it is a property of an object you will want to initialize it in the constructor.

nickles80
  • 1,091
  • 8
  • 10