就是我根据用户的信息比如用户输入5,那我就要进行5项实例化
这要如何实现呢???

解决方案 »

  1.   

    本帖最后由 caozhy 于 2013-02-26 22:23:25 编辑
      

  2.   

    List<YourClass> list = new List<YourClass>();
    int n = int.Parse(Console.ReadLine());
    for (int i = 0; i < n; i++)
        list.Add(new YourClass());
      

  3.   

    楼主是想要这个效果么            int userInput = System.Int32.Parse(Console.ReadLine());
                for (int i = 0; i < userInput; i++)
                {
                    Console.WriteLine("i =" + i);
                    //new something
                }
                Console.ReadLine();
      

  4.   

    呃那要是PointF怎么做这种操作呢?
      

  5.   


    不是,比如我现在用户需要创建5个PointF的实例,要怎么自动判断需要创建多少个实例,比如6个的话它又会自动创建6个,
      

  6.   

    一样的啊
    List<PointF> list = new List<PointF>();
    int n = int.Parse(Console.ReadLine());
    for (int i = 0; i < n; i++)
        list.Add(new PointF(0.0, 0.0));
      

  7.   

    没用过List,刚开始理解错了
    明早试试看,谢谢你!!
      

  8.   

    根据用户输入的数字。生成几个都无所谓的。
    用List<Point>或者数组都行。
    for就解决了。