Click here to Skip to main content
15,892,269 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
string sInput ="";
sInput =
MLOOPO BW 21      1     2       15     15      0    0      0     30    0 <br />
MLOOPI IC 23     0     0 *      0      0                              ''    ''   30    0 


I need to get the value per row using the split to get the exact value per column

The problem is when the value is null or space I need to Identify in order for me to save in a column assigned as null or blank. What is happening is the value for column 10 goes to column 7 becuase the value of column 7 is null.

my code below to get value

string[,] ADPH = new string[13,13];
int iData_x = 0;

string[] sValue = sInput.Split(' ');
int y = 0;

foreach (string sword in sValue)
{
 if (!string.IsNullOrEmpty(sword))
    {
     ADPH[iData_x, y] = sword;
     y = y + 1;
    }
}
Posted

Why don't you turn the string into a byte array and iterate over it that way ? What are you trying to do ? You know the array is 13 x 13, so don't trust the data to tell you when to step over the values ( although iData_x never changes in this code ), just iterate over it using your known values.
 
Share this answer
 
Can you give me an example on how to use Iterate since I haven't tried it. Thanks for your quick reply
 
Share this answer
 
It would be easier if you edited your post instead of posting a bogus 'answer' that's really another question. Assuming you HAVE a 13x13 array of data, and not just what you posted:

for (int x = 0; x < 13; ++x)
for (int y = 0; y < 13; ++y)
{

ADPH[x,y] = sValue[x+(y*13)];

}

Off the top of my head. Assuming your string array is correct. Like I said, I'd do that with a byte array, personally.
 
Share this answer
 

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