C#, dynamic object names?

前端 未结 8 587
情歌与酒
情歌与酒 2020-12-21 20:07

Suppose I have a list of objects

List DogList = new List();

and I want to automatically add objects to it, li

8条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-21 21:06

    for (int i = 0; i < 10; i++)
    {
        dogClass myDog = new dogClass();
        DogList.Add(myDog);
    }
    

提交回复
热议问题