| | |
ArrayList from something other than primitives
Please support our C# advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Aug 2007
Posts: 164
Reputation:
Solved Threads: 1
Hi. I need some help with arraylists. i can do a basic arraylist which uses integers and strings and so on. but what i need is an arraylist composed of something else.
best would be an arraylist composed of arraylists. like a multi dimensional array. is it possible to create multi dimensional arrays and if it is then how does one use it? if you guys can just give me basic guide lines for creating, adding, reading and removing
otherwise can i use the array list with an array of strings. or with a set of class objects. if i use it with an array of strings then what do i use as in the cast operation? can i just use the string array int the form (string[])? and if i use class objects which i create then i suppose that i can use the class in the cast
best would be an arraylist composed of arraylists. like a multi dimensional array. is it possible to create multi dimensional arrays and if it is then how does one use it? if you guys can just give me basic guide lines for creating, adding, reading and removing
otherwise can i use the array list with an array of strings. or with a set of class objects. if i use it with an array of strings then what do i use as in the cast operation? can i just use the string array int the form (string[])? and if i use class objects which i create then i suppose that i can use the class in the cast
... what society overwhelmingly asks for is snake oil. Of course, the snake oil has the most impressive names —otherwise you would be selling nothing— like "Structured Analysis and Design", "Software Engineering", "Maturity Models", "IPSE", "MIS", "OO", "BPRE".... by Edsger W. Dijkstra
ok, here is an example: data is stored in xml and represents the table, need array list of array lists of xml nodes to do some intelligent sorting
this is very simplified, but at the end you get:
ArrayList that holds multiple array lists that holds multiple xml nodes that should be grouped together for some reason.
to work this:
So the answer - multi dimensional arrays are good for you and are possible. Remember ArrayList holds object and everything is an object (even collections like arraylsits)so there is no limit. I have simplified this example but using casting you can get to any element within a top or bottom level of your arraylist.
Paul
C# Syntax (Toggle Plain Text)
ArrayList _arrMaster = new ArrayList foreach(XmlNode rNode in XmlTable) { if(IsStartOfGroup(rNode)) //if we need to start up a group I need a new array list { ArrayList _arrSub = new ArrayList(); _arrSub.Add(rNode); /*add few more xml nodes and then move to the next group */ _arrMaster.Add(_arrSub); } }
ArrayList that holds multiple array lists that holds multiple xml nodes that should be grouped together for some reason.
to work this:
C# Syntax (Toggle Plain Text)
private void ReIndexMaster(ref ArrayList master) { int iRowCount = 1; int iCellCount = 1; foreach(ArrayList tmp in master) { foreach(XmlNode rNode in tmp) { rNode.Attributes["index"].Value = iRowCount.ToString(); rNode.Attributes["o_index"].Value = iRowCount.ToString(); iRowCount += 1; iCellCount = 1; foreach(XmlNode cNode in rNode) { cNode.Attributes["index"].Value = iCellCount.ToString(); iCellCount += 1; } } } }
Paul
===========================
can you repeat the part of the stuff where you said all about the things?
can you repeat the part of the stuff where you said all about the things?
![]() |
Similar Threads
- Using operator[] with an ArrayList (Java)
- Is ArrayList Better than Vector (Java)
- Storing Point2D.Double objects in an ArrayList. (Java)
- Need Help with ArrayList sorting (Java)
- Linked arraylist (Java)
Other Threads in the C# Forum
- Previous Thread: Displaying an XML table
- Next Thread: Problem with Form and Combox selections
| Thread Tools | Search this Thread |
.net access algorithm array asp.net barchart bitmap box broadcast c# check checkbox client combobox control conversion csharp custom database databaseconnection datagrid datagridview dataset datetime dbconnection degrees design development draganddrop drawing encryption enum event eventhandlers excel file firefox form format forms function gdi+ grantorrevokepermissionthroughc#.net httpwebrequest image index input install java label libraries list listbox loop mandelbrot marshalbyrefobject math mouseclick movingimage mysql mysql.data.client operator path photoshop picturebox pixelinversion platform post programming radians regex remote remoting resourcefile richtextbox server sleep socket sql statistics stream string system.servicemodel table tcpclientchannel text textbox thread time timer update usercontrol validation visualstudio webbrowser windows winforms wpf wpfc# xml





