hi i have an string array in which i have combinations of 0's and 1's like on index 0 i have "01", on index 1 i have "11", on index 2 i have "00", on index 3 i have"10" etc is their any possibilty that i can take these values as binary and then convert them into decimal like
01 = 1
11 = 3
00 = 0
10 = 2
let me clear i am not talking about connverting string to binary i want that string as binary
thanks in advance:)

A way to do what I guess you want is:

string str;
     int i = -1;
     str = "10"; // value of a certain index in your stringarray
     switch ( str)                       
     {
          case "00": i = 0; break;
          case "01": i = 1; break;
          case "10": i = 2; break;
          case "11": i = 3; break;              
     }

thanks ddanbe but may be i was unable to explain it properly
actually what i was trying i got whole in a single line
Convert.ToInt64((arr1[i] + arr2[i]),2)
though i was thinking that it might not give me the right ans but it does i was wrng

So your question all boils down to something like Int64 WhenIm64 = Convert.ToInt64("01" + "11", 2); Wich would make WhenIam64 equal to 7. So I guess this is solved, happy programming!

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.