I have a string with a digit of 4353816274931243 i want to multiply every odd position in the string. So at the end it should look like 831031611221441832283.
I tried to use an if statement like so.
if(cijfer%2==0)
{
cijfer = cijfer*2
}
but this just finds all odd numbers in the string and multiplies them. Any one got any tips on how to solve this problem?
This is the part of code i already have.
string num;
int visanr, cijfer=0;
console.write("Enter visa number: ");
num=console.readline();
num = num.Replace(" ", "");
visanr = num.Length;
if (visanr==16)
{
for (int i = 0; i < visanr; i++)
{
string num1 = num.Substring(i, 1);
cijfer = int.Parse(num1);
if (cijfer%2==0)
{
cijfer = cijfer * 2;
}
}
}
else
{
Console.Write("The visanumber " + num + " is not correct!");
}
Console.Read();
Thanks in advance