demo类的变量是私有的 Demo d[]=new Demo[];
然后怎么 手动输入对象数组? 

解决方案 »

  1.   

    List<Demo> list=new List<Demo>;
    list.Add();
      

  2.   

    我更喜欢ArrayList.ArrayList AL = new ArrayList();Demo d = new Demo();
    ....
    AL.Add(d);
      

  3.   

    Demo[] d = new Demo[]
    {
        new Demo() { xxx = xxx, xxx = xxx },
        new Demo() { xxx = xxx, xxx = xxx },
        ...
    };
      

  4.   

    额,我明白了,lz想要的是ironpython或powsershell一类的交互平台或者caozhy版主上次推荐的Roslyn CTP
      

  5.   

    http://www.codeproject.com/Articles/113169/C-As-A-Scripting-Language-In-Your-NET-Applications
      

  6.   


    我觉得三种形式都是可以的:
    List<Demo> list=new List<Demo>;
    ArrayList<Demo> list=new ArrayList<Demo>();
    Demo[] d = new Demo[]
    {
    new Demo() { para1= xxx, para2= xxx },
    new Demo() { para1= xxx, para2= xxx },
    ...
    };但是第一种是泛型是最好的方式.
      

  7.   

    //其实我现在想要 手动输入数组个数不只有三个  还要手动忘数组输入属性 比如下面有四个属性。 怎么实现??
                //手动输入商品信息
               
                string[] good1 = new string[3];
                string[] good2 = new string[3];
                string[] good3 = new string[3];
                //Console.WriteLine("请输入商品属性:");
                //for (int i = 1; i < 2; i++)
                //{
                //    string god = "good" + i;
                //    string[] god = new string[3];//商品属性
                //}
                Console.WriteLine("请输入商品个数:");
                int num = Console.Read();
                for (int i = 0; i < num;i++ )
                {
                    Console.WriteLine("请输入商品信息:\n名字:");
                    good1 [i] = Console.ReadLine(); ;
                    Console.WriteLine("位置:");
                    good1[i] = Console.ReadLine();
                    Console.WriteLine("价格:");
                    good1[i] = Console.ReadLine();
                    Console.WriteLine("满意度:");
                    good1[i] =  Console.ReadLine();
                }
      

  8.   

    我代码很乱啊 是有不对的 呵呵 帮我看看呀  之前学的java 还是有挺多不一样的啊java可以用这里不可以啊好像。