C# F中的对象数组或列表#
我有一个从button()派生的自定义button类: 如何像下面的C代码那样,在F中创建Game15按钮数组C# F中的对象数组或列表#,c#,.net,f#,functional-programming,C#,.net,F#,Functional Programming,我有一个从button()派生的自定义button类: 如何像下面的C代码那样,在F中创建Game15按钮数组 MyButton[] buttons = new MyButton[16]; int i = 0; for (int y = 0; y < 4; y++) for (int x = 0; x < 4; x++){ buttons[i] = new MyButton(); buttons[i].Size = new Size(50,
MyButton[] buttons = new MyButton[16];
int i = 0;
for (int y = 0; y < 4; y++)
for (int x = 0; x < 4; x++){
buttons[i] = new MyButton();
buttons[i].Size = new Size(50, 50);
buttons[i].Pozition = new Point(x, y);
i++;
}
MyButton[]按钮=新建MyButton[16];
int i=0;
对于(int y=0;y<4;y++)
对于(intx=0;x<4;x++){
按钮[i]=新的MyButton();
按钮[i]。尺寸=新尺寸(50,50);
按钮[i]。Pozition=新点(x,y);
i++;
}
如果需要数组,请使用
[|…|]
。您对翻译的哪一部分有问题?@JohnPalmer我想我可以使用F#中的System.Collections.Generic,thanx
MyButton[] buttons = new MyButton[16];
int i = 0;
for (int y = 0; y < 4; y++)
for (int x = 0; x < 4; x++){
buttons[i] = new MyButton();
buttons[i].Size = new Size(50, 50);
buttons[i].Pozition = new Point(x, y);
i++;
}
let buttons = [
for y in {0..3} do
for x in {0..3} do
yield Game15Button(Point(x, y), Size = Size(50, 50))
]