public List<PControl> PShows = new List<PControl>();

for(int i=0;i<Datas.PShowDatas.Count;i++)
            {
                PShows.Add(new PControl());
                PShows[i].Margin = new Thickness(3, 3, 10, 3);

                PShows[i].ID = i + 1;
       }

即先定义一个List,再for循环中添加一个对象,使用LIst[i]对该对象进行设置

更多推荐