向同学请教后搞明白了把结构装进数组的方法,原来很简单:- public struct DayQty
- {
- public string userAccont;
- //public DateTime startDate;
- public DateTime startTime;
- //public DateTime endDate;
- public DateTime endTime;
- public decimal dayQty;
- }
- static void Main()
- {
- DayQty[] dr = new DayQty[10];
- //可以写成方法AddData()
- dr[0].userAccont = "101";
- dr[0].startTime = new DateTime(2013, 7, 1, 8, 30, 0);
- dr[0].endTime = new DateTime(2013, 7, 1, 18, 0, 0);
- //dr[0].dayQty = 0.0m;//不赋值即默认为0
- dr[1].userAccont = "102";
- dr[1].startTime = new DateTime(2013, 7, 1, 10, 0, 0);
- dr[1].endTime = new DateTime(2013, 7, 1, 18, 0, 0);
- //dr[1].dayQty = 0.0m;
- Console.WriteLine(dr[0].startTime);
- Console.WriteLine(dr[0].dayQty);
- Console.ReadKey();
- }
复制代码 估计楼主的程序是用数据库的,我是当成控制台程序思考的。 |