【发布时间】:2012-03-06 07:27:26
【问题描述】:
Public Structure testStruct
Dim blah as integer
Dim foo as string
Dim bar as double
End Structure
'in another file ....
Public Function blahFooBar() as Boolean
Dim tStrList as List (Of testStruct) = new List (Of testStruct)
For i as integer = 0 To 10
tStrList.Add(new testStruct)
tStrList.Item(i).blah = 1
tStrList.Item(i).foo = "Why won't I work?"
tStrList.Item(i).bar = 100.100
'last 3 lines give me error below
Next
return True
End Function
我得到的错误是:表达式是一个值,因此不能成为赋值的目标。
为什么?
【问题讨论】:
-
简单的解决方案:不要使用结构,使用类?