Search code examples
vb.netbinaryflip

How in Visual Basics change characters in a string for example (1 to 0) and (0 to 1)?


How in Visual Basics change characters in a string for example (1 to 0) and (0 to 1) without the problem of changing them first to all to 0 and then all to 1, i want to get a result for example like that "00110010101101001010" to "11001101010010110101" (to flip it)


Solution

  • Use an intermediate value.

    Change all 0 -> 2
    Change all 1 -> 0
    Change all 2 -> 1