| | |
Unboxing an ArrayList in an object
Please support our C# advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved |
•
•
Join Date: Jul 2009
Posts: 31
Reputation:
Solved Threads: 0
I'm probably going about this in the wrong way, but I have a stack of Objects, and some of these can be ArrayLists. I want to be able to pop an object that is actually an ArrayList off the stack, unbox it, add something, and then pop it back on. For example:
Does anyone have an idea of how to do what I'm trying to do?
Thanks in advance
C# Syntax (Toggle Plain Text)
Stack<Object> s = new Stack<Object>(); ArrayList l = new ArrayList(); Object x; s.Push(l); x = s.Pop(); x = (ArrayList)x; //This is the line I don't know how to do x.Add("Something"); s.push(x);
Does anyone have an idea of how to do what I'm trying to do?
Thanks in advance
Last edited by tdeck; Jul 23rd, 2009 at 11:16 am.
do in this way:
C# Syntax (Toggle Plain Text)
............... Object x; x = s.Pop(); ArrayList al=x as ArrayList ; if(al!=null) { al.Add("Something"); } ...............
Freedom in the Mind, Faith in the words.. Pride in our Souls...
Indian Developer
http://falaque.wordpress.com/
Indian Developer
http://falaque.wordpress.com/
![]() |
Similar Threads
- ArrayList<MyClass>, help writing MyClass (Java)
- Open a text file from another project (VB.NET)
- Really really strugglisng with Jlist (Java)
- unsafe operation (Java)
- I want to learn - How to create and use objects. (C#)
- Weird JTable behaivour (Java)
- indexing (C#)
- Having trouble with comparing strings and arrays (Java)
Other Threads in the C# Forum
- Previous Thread: Comparing gridview with a datatable or gridview and highlight them
- Next Thread: how to sort dictionary?
Views: 498 | Replies: 2
| Thread Tools | Search this Thread |
Tag cloud for C#
.net access ado.net algorithm array barchart bitmap box broadcast button c# chat check checkbox class client code color combobox control conversion csharp custom database datagrid datagridview dataset datetime degrees development draganddrop drawing encryption event excel file files form format forms ftp function gcd gdi+ http httpwebrequest image index input install java label list listbox listener login math mouseclick mysql networking object operator path photoshop picturebox pixelinversion post prime programming radians regex remote remoting resource saving serialization server sleep socket sql statistics stream string tcp text textbox thread time timer treeview update usercontrol validation view visualstudio webbrowser windows winforms wpf xml





