Button[] btn = new Button[35];
for (int i = 0; i < 35; i++)
{
for (int j = 1; j < 6; j++)
for (int h = 0; h < 7; h++)
{
btn[i].Padding = new Thickness(28, 10,28,10);
btn[i].FontSize = 26;
btn[i].Foreground = Brushes.Red;
btn[i].SetValue(Grid.RowProperty, j);
btn[i].SetValue(Grid.ColumnProperty, h);
}
grid2.Children.Add(btn[i]);
}
调试的时候就是说btn[i].Paddding这句有问题,说“未将对象引用设置到对象实例”,请问应该如何解决?