| | |
Help with ArrayList as returned argument
Please support our ASP.NET advertiser: Intel Parallel Studio Home
Thread Solved |
•
•
Join Date: Sep 2007
Posts: 86
Reputation:
Solved Threads: 1
I have this ArrayList that consist of list of structure and I would like to use the content of the ArrayList as the return type for the function bellow. Can anyone help please.
ASP.NET Syntax (Toggle Plain Text)
public struct DeviceSchedules { public string StartDate; public string EndDate; public string Interval; public string DeviceTimeZone; public string GLRID; public string TrackUID; } [WebMethod()] public DeviceSchedules theSchedules() { ArrayList ZoneArray = new ArrayList(); ZoneArray.Add("PST"); ZoneArray.Add("MST"); ZoneArray.Add("CST"); ZoneArray.Add("EST"); DeviceSchedules Schedules = new DeviceSchedules(); ArrayList GroupSchedule = new ArrayList(); Int16 Zone = 1; DateTime Begining = DateTime.Now.AddHours(Zone); DateTime End = DateTime.Now.AddHours(Zone); //int Zone = 3; Int32 TrackID = 9999; Int32 ScheduleID = 400; int Frequency = 40; for (int index = 0; index <= 5; index++) { Schedules.StartDate = Convert.ToString(Begining); Schedules.EndDate = Convert.ToString(End); Schedules.Interval = Convert.ToString(Frequency); Schedules.DeviceTimeZone = Convert.ToString(ZoneArray[Zone]); Schedules.GLRID = Convert.ToString(ScheduleID); Schedules.TrackUID = Convert.ToString(TrackID); GroupSchedule.Add(Schedules); } return (GroupSchedule); }
•
•
Join Date: Sep 2007
Posts: 86
Reputation:
Solved Threads: 1
The correct implementation to the above question is as follow
This is kind of "?!@#$%%^&*(@"...
ASP.NET Syntax (Toggle Plain Text)
public struct DeviceSchedules { public string StartDate; public string EndDate; public string Interval; public string DeviceTimeZone; public string GLRID; public string TrackUID; } [WebMethod()] public DeviceSchedules[] theSchedules() { ArrayList ZoneArray = new ArrayList(); ZoneArray.Add("PST"); ZoneArray.Add("MST"); ZoneArray.Add("CST"); ZoneArray.Add("EST"); DeviceSchedules Schedules = new DeviceSchedules(); ArrayList GroupSchedule = new ArrayList(); Int16 Zone = 1; DateTime Begining = DateTime.Now.AddHours(Zone); DateTime End = DateTime.Now.AddHours(Zone); //int Zone = 3; Int32 TrackID = 9999; Int32 ScheduleID = 400; int Frequency = 40; for (int index = 0; index <= 5; index++) { Schedules.StartDate = Convert.ToString(Begining); Schedules.EndDate = Convert.ToString(End); Schedules.Interval = Convert.ToString(Frequency); Schedules.DeviceTimeZone = Convert.ToString(ZoneArray[Zone]); Schedules.GLRID = Convert.ToString(ScheduleID); Schedules.TrackUID = Convert.ToString(TrackID); GroupSchedule.Add(Schedules); } return ((DeviceSchedules[])GroupSchedule.ToArray(typeOf(DeviceSchedule))); }
This is kind of "?!@#$%%^&*(@"...
•
•
Join Date: Sep 2007
Posts: 86
Reputation:
Solved Threads: 1
I am still trying to understand why the latter works. I agree with your suggestion and it should have worked; But I guessed there is a special convention about ArrayList we must understand. Information like that doesn't exist in books. I had to dig through the MSDN to get the aforementioned implementation.
![]() |
Similar Threads
- Source Code that don't work? (Java)
Other Threads in the ASP.NET Forum
- Previous Thread: .exe file
- Next Thread: Open file Dialog in asp.net
| Thread Tools | Search this Thread |
Tag cloud for ASP.NET
.net 2.0 3.5 ajax alltypeofvideos appliances application asp asp.net beginner box browser businesslogiclayer button c# cac checkbox class complex control countryselector dataaccesslayer database datagrid datagridview datalist deployment development dgv dialog dropdownlist dropdownmenu dynamic dynamically edit editing embeddingactivexcontrol feedback fileuploader fill findcontrol flash folder form gridview gudi iis image javascript languages list listbox maps mobile mouse mssql nameisnotdeclared news novell numerical opera panelmasterpagebuttoncontrols parent problem profile project radio redirect registration relationaldatabases reportemail response.redirect richtextbox rows schoolproject search security select sessionvariables silverlight smoobjects software sql sql-server ssl tracking treeview validatedate validation vb.net videos vista visualstudio vs2008 web webapplications webdevelopment webprogramming wizard xsl






