T
tshad
I am trying to convert a string character to an int where the string is all
numbers.
I tried:
int test;
string stemp = "5";
test = Convert.ToInt32(stemp[0]);
But test is equal to 53.
If I change it to:
test = Convert.ToInt32(stemp);
Then it works the way I want where test = 5.
What I am doing is going through the string one by one and doubling the even
number characters and putting them back into another string:
Here is a snippet of the code where creditCard is a string.
****************************************
string sDigits = null;
for(int ktr=0;ktr<creditCard.Length;ktr++)
{
if (((ktr+1)%2) == 0)
sDigits += Convert.ToString(Convert.ToInt32(creditCard[ktr]) * 2);
else
sDigits += Convert.ToString(creditCard[ktr]);
}
*********************************************
Thanks,
Tom
numbers.
I tried:
int test;
string stemp = "5";
test = Convert.ToInt32(stemp[0]);
But test is equal to 53.
If I change it to:
test = Convert.ToInt32(stemp);
Then it works the way I want where test = 5.
What I am doing is going through the string one by one and doubling the even
number characters and putting them back into another string:
Here is a snippet of the code where creditCard is a string.
****************************************
string sDigits = null;
for(int ktr=0;ktr<creditCard.Length;ktr++)
{
if (((ktr+1)%2) == 0)
sDigits += Convert.ToString(Convert.ToInt32(creditCard[ktr]) * 2);
else
sDigits += Convert.ToString(creditCard[ktr]);
}
*********************************************
Thanks,
Tom