Properties in Structures: “Expression is a value and therefore cannot be the target of an assignment.”

五迷三道 提交于 2019-12-05 03:57:52

It's just a matter of what is happening when you run the program. The getter returns a copy of your struct, you set a value on it, then that copy of the struct goes out of scope (so the modified value doesn't do anything). The compiler shows this as an error since it is probably not what you intended. Do something like this:

Dim tempRightHand as HandStruct
tempRightHand = myHuman.Right
tempRightHand.Length = 70
myHuman.Right = tempRightHand

The left works because you are accessing it directly instead of through a property.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!