wpf为何在c#代码里创建了Button对象在调试时就出错要我去创建Button?

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这句有问题,说“未将对象引用设置到对象实例”,请问应该如何解决?

你只是new了一个数组对象,不是new了35个button对象,所以加上new Button 试试

 btn[i]=new Button();