| | |
ArrayList to multi-dimensional string array
Please support our C# advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Dec 2004
Posts: 1,655
Reputation:
Solved Threads: 35
Consider the following code snippet:
There has got to be a better way to do this! The issue is, the ps.Operations property requries a 2-dimensional string array. (It's a list of operations to peform on a PostScript file, along with the parameters needed for each operation.)
I build that array dynamically, which means creating an ArrayList, which is "OPERATIONS" in the code. The challenge is to get the members of the ArrayList into a suitable string array. The above code is my solution.
There should be a way to do this without resorting to a loop. Just a couple of lines of code with some judicious casting, but I couldn't make anything work.
C# Syntax (Toggle Plain Text)
counter = 0; workOperations = new String [OPERATIONS.Count,2]; foreach ( System.Array o in OPERATIONS) { workOperations[counter,0] = (string) o.GetValue(0,0); workOperations[counter,1] = (string) o.GetValue(0,1); counter++; } ps.Operations = workOperations;
There has got to be a better way to do this! The issue is, the ps.Operations property requries a 2-dimensional string array. (It's a list of operations to peform on a PostScript file, along with the parameters needed for each operation.)
I build that array dynamically, which means creating an ArrayList, which is "OPERATIONS" in the code. The challenge is to get the members of the ArrayList into a suitable string array. The above code is my solution.
There should be a way to do this without resorting to a loop. Just a couple of lines of code with some judicious casting, but I couldn't make anything work.
![]() |
Similar Threads
- Error with array structures :( (C++)
- Creating a multi-dimensional Session variable (PHP)
- Passing multi-dimensional array (C)
- Multi-dimensional Arrays: (Python)
- multi dimensional array search xml parser (PHP)
- Need help passing a multi-dimensional array (C++)
- two-dimensional char array (Java)
Other Threads in the C# Forum
- Previous Thread: Array["name"] instead of Array[int]
- Next Thread: Data stored in Records
Views: 53915 | Replies: 2
| Thread Tools | Search this Thread |
Tag cloud for C#
.net access ado.net algorithm array barchart bitmap broadcast button buttons c# check checkbox class client code color combobox control conversion csharp custom database datagrid datagridview dataset datetime degrees development draganddrop drawing event excel file files form format forms ftp function gdi+ http httpwebrequest image index input install java label list listbox listener login mandelbrot math mouseclick mysql networking object operator path picturebox pixelinversion post prime programming radians regex remote remoting resource richtextbox save saving serialization server sleep socket sql statistics stream string table tcp text textbox thread time timer treeview update usercontrol validation view visualstudio webbrowser windows winforms wpf xml






