I have been assigned this project to create a dynamic key code and I don't have a clue about how I can get it done.

The problem:

I am given a 10 digit number like a phone number 5627775698 and I need to parse through the number and set every other digit to zero starting with the the first digit. Then I need to convert that number to Binary and apply a mask like 1111111111 then add the two numbers together.

I already know how to apply the mask and adding the two numbers together but I need a system or technique to solve the first part of the problem.

Any suggestion?

If it is always 10 digits, it's easy.

One way to do it would be to remove every other digit, then you end up with

Dim String1 as String = 1234567891
String1 = 0 & String1.Substring(1,1) & "0" & string1.substring(3,1) & "0" & string1.substring(5,1) ....
... that gives you the idea.

I am using C# and I've tried to implement the method below but when i ran it, I got "0700000100 for this number 6784855146" Can someone point out why I got this result?

protected void MaskMSID()
    {
        StringBuilder MSIDKey = new StringBuilder(this.MSID);
        for (int index = 0; index < MSIDKey.Length; index += 2)
        {
            MSIDKey.Replace(MSIDKey[index], '0');                
        }
        this.MSID_Mask = MSIDKey.ToString();
    }
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.