怎么在c#手动输入对象数组? demo类的变量是私有的 Demo d[]=new Demo[];然后怎么 手动输入对象数组? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 List<Demo> list=new List<Demo>;list.Add(); 我更喜欢ArrayList.ArrayList AL = new ArrayList();Demo d = new Demo();....AL.Add(d); Demo[] d = new Demo[]{ new Demo() { xxx = xxx, xxx = xxx }, new Demo() { xxx = xxx, xxx = xxx }, ...}; 额,我明白了,lz想要的是ironpython或powsershell一类的交互平台或者caozhy版主上次推荐的Roslyn CTP http://www.codeproject.com/Articles/113169/C-As-A-Scripting-Language-In-Your-NET-Applications 我觉得三种形式都是可以的: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 },...};但是第一种是泛型是最好的方式. //其实我现在想要 手动输入数组个数不只有三个 还要手动忘数组输入属性 比如下面有四个属性。 怎么实现?? //手动输入商品信息 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(); } 我代码很乱啊 是有不对的 呵呵 帮我看看呀 之前学的java 还是有挺多不一样的啊java可以用这里不可以啊好像。 再开一贴,解决问题两个帖子一起给分! 正则替换0的问题 谁能帮我解决一下这个问题,关于Textbox的 大虾必看!帮忙看! FileSystemWatcher的filter c#2.0中tablelayoutpanel做的表格 如何使其每行背景颜色不同 或者间隔颜色 一个关于datagrid的简单问题!~~~~ 新年快乐 文本文件查找替换问题? 我如何改变原来空间的属性? IEnumerable<InnerBoundary> 和 List<InnerBoundary> 有什么区别 工商银行ASP.NET接口开发出现如下错误怎么解决
list.Add();
....
AL.Add(d);
{
new Demo() { xxx = xxx, xxx = xxx },
new Demo() { xxx = xxx, xxx = xxx },
...
};
我觉得三种形式都是可以的:
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 },
...
};但是第一种是泛型是最好的方式.
//手动输入商品信息
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();
}