Array from large number - how to

  • Thread starter Thread starter kilsoft
  • Start date Start date
K

kilsoft

I am creating a web form to generate a calculation based on a 2 digit
input from a user. Depending on their input it creates an array prefix
of numbers. The 2nd part of the array comes from an access database
where it holds the next available number. This is where the problem
sets in, when I pull the 8 digit number from the db I cannot get it
into an array. I need each digit split apart into the array. I can read
it as an Int but am not sure how to read it as an array.

Ultimately I need to merge the array prefix with the array from the db
so I can do a calculation on each digit.

Any help is appreciated. Thanks.

// code snip
string NEWid = myCMD.ExecuteScalar().ToString(); // these lines.
int newID = Convert.ToInt32(NEWid); // are my stupid
int [] newID2; // newbie problems
newID2=new int[20]; // described above
newID2=newID; //

int[] combArray=new int[18];
arrPrefix.CopyTo(combArray,0);
 
Don't worry, it's pretty easy to do that.

string newID = myCmd.ExecureScalar().ToString();

int[] numberArray = new int[newID.Length];

for(int i = 0; i < newID.Length; i++)
numberArray = int.Parse(newID.ToString());

and there you have it ... each digit of your number is now in one of the
elements of numberArray.

Note that this code does not do error checking, the code can potentially
fail if non-digits appear in the newID string.

HTH
Cordell Lawrence
 
Back
Top