Expression is a value and cannot be the target of an assignment

If i have a structure:

Structure Cow Public Moo As String End Structure 

And in Main():

 Dim Herd As New List(Of Cow) Herd.Add(New Cow) Herd(0).Moo = "moof" Dim Dog = Herd(0) Dog.Moo = "moof" 

Herd(0).Moo = “moof” errors with Expression is a value and cannot be the target of an assignment.

Why does one work and the other not?

(I understand that i can add a method to the structure to set the variable. I just want to know why i can hit the variable directly in one case but not the other.)

submitted by /u/chacham2
[link] [comments]

Leave a Reply