C#, dynamic object names?

前端 未结 8 592
情歌与酒
情歌与酒 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 20:42

    Im not sure what are your intentions, but maybe you want to that in a loop:

      for(int i = 0; i < 10; i++)
      {
         dogList.Add(new DogClass());
      }
    

提交回复
热议问题