program Produce;
var
A : array [1..10] of Integer = (1,2,3,4,5,6,7,8,9);
begin
end.
=============================================
现在我需要上面可以通过编译,这样可以做到吗?
=============================================
以下是官方的资料:
http://docs.embarcadero.com/products/rad_studio/delphiAndcpp2009/HelpUpdate2/EN/html/devcommon/cm_initialize_count_xml
------解决方案--------------------------------------------------------
官方资料都告诉你了,这是不行的.
初始化赋值,后期赋值都需要赋相匹配类型的值.
在C# 中也是不行的.
- C# code
protected void Page_Load(object sender, EventArgs e) { int[] i = new int[3] { 1, 2 }; //直接报错 } protected void Page_Load(object sender, EventArgs e) { int[] i = new int[2] { 1, 2 }; int[] j = new int[3] { 3, 3, 3 }; i = j; //这样是可以滴 }
------解决方案--------------------------------------------------------
- Delphi(Pascal) code
ii : array[1..5] of integer = (1,2,3,4,5);