Click here to Skip to main content
15,895,656 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
This is my code and i want to have the mapfull map* stuff but its in ASCII(or something) and i want to turn it "normal". be1/2/3 are strings that are consist of an 81 char long numbers (example: 79456123...). Can you help me?

C#
int ind1 = 0;
            int ind2 = 0;
            int ind3 = 0;
            //MessageBox.Show(be1);
            for (int i = 0; i <= 8; i++)
            {
                for (int j = 0; j <= 8; j++)
                {
                    mapFull[i, j] = be1[ind1++];
                    mapInitial[i, j] = be2[ind2++];
                    mapCurrent[i, j] = be3[ind3++];
                }
            }
Posted

1 solution

Assuming mapFull, mapInitial and mapCurrent are arrays of int, then this should do:
C#
mapFull[i, j] = (int)be1[ind1++] - '0';
mapInitial[i, j] = (int)be2[ind2++] - '0';
mapCurrent[i, j] = (int)be3[ind3++] - '0';


Edit: Keep in mind that this solution is "stupid" - if there are non-digit characters in your string, you won't get an error / exception. So you have to ensure that the strings are purely made of digits before using this. But your question reads like that is the case, so I suggested this approach.
 
Share this answer
 
v2
Comments
Member 11338785 3-Apr-15 8:48am    
THANK YOU SOOOO MUCH!!!!
Sascha Lefèvre 3-Apr-15 8:50am    
You're welcome!
Sascha Lefèvre 3-Apr-15 10:17am    
I added a comment to the solution, please take a look.
Member 11338785 3-Apr-15 10:22am    
Yep, they are ONLY contain numbers.

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