Click here to Skip to main content
15,902,899 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a large ammount of data read in a text box that I then need to split up
if I use a foreach statement to seperate on a character (#0D for instance)
I then need to split them in to array of strings will this be making life difficult
if I use the below (with delimeters as #0D)

string Data;
           //string[Number_Records] = Data_Values[Number_Records];
           int a =0;
           Data = rtbReturnedData.Text;
          // MessageBox.Show(Data);
           foreach (string subString in Data.Split(delimeters))
              // Data_Values[a] = subString;

The problem is subString then contains the seperate values, now I ideally need an array of strings that I can copy subString into an increase via the a integer.

The Number_Records is assigned before this point to allow for upload variable length files am i declaring the string array right? my intention as the values read back as hex, my thinking was a string is the best method of holding them, but all the examples I can find of string arrays use
string[Number_Records] = Data_Values[Number_Records];

but I can't seem to get it to work.
Sergey Alexandrovich Kryukov 12-Jan-12 11:51am    
Not clear? What is Number_Records, Data_Values? In "string[Number_Records] = ", where is the variable?!
What did you mean to do? What is "copy subString into an increase via the a integer". Even though you are doing something very simple, this is not answerable. Try "Improve question" above.

1 solution

Your issue can be solved much simpler with a small modification.
string Data;
int a=0;
string[] stringParts = Data.Split(delimeters);

Now you have a string array of the parts. If you look at string.Split, you will see that the return value is already the string array which is what you want.
Share this answer
glennPattonWork3 12-Jan-12 10:37am    
Thanks for that, I was not aware of that, or in fact I had posted the question due to a blue screen (this PC is dying)
Sergey Alexandrovich Kryukov 12-Jan-12 11:52am    
Re-install the OS - maybe PC is not exactly dying.
Sergey Alexandrovich Kryukov 12-Jan-12 11:53am    
I don't know how you managed to understand the question; my 5 is just for that. :-)
glennPattonWork3 13-Jan-12 6:06am    
As I said PC died, it's not the OS it's a board issue due to overheating I'm guessing by the smell lack of heat sink compound used to add a very odd heatsink to a custom board! I was amazed I posted it and got a reply before my PC came back from the dead.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900