0 arrays delphi record oxygene delphi-prism
我正在学习Delphi Prism,我没有找到如何用它编写以下代码:
type
TRapportItem = record
Label : String;
Value : Int16;
AnomalieComment : String;
end;
type
TRapportCategorie = record
Label : String;
CategoriesItems : Array of TRapportItem;
end;
type
TRapportContent = record
Categories : array of TRapportCategorie;
end;
Run Code Online (Sandbox Code Playgroud)
然后,在某个地方,我尝试将项目放在数组中:
rapport.Categories[i].Label:=l.Item(i).InnerText;
Run Code Online (Sandbox Code Playgroud)
但它不起作用.有人可以点燃我吗?
谢谢!
nil.它们需要在访问元素之前进行初始化.您可以与new运营商一起执行此操作:
rapport.Categories = new TRapportCategorie[10]; // 0..9
Run Code Online (Sandbox Code Playgroud)
List<T>.所以你要声明:
Categories: List<TRapportCategorie>;
Run Code Online (Sandbox Code Playgroud)
new运算符进行初始化.此外,修改包含值类型的列表上的索引器的返回值将修改副本,而不是原始副本,这将导致下一个点.| 归档时间: |
|
| 查看次数: |
2003 次 |
| 最近记录: |