Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

splitting a string into an array

$
0
0

 Random r = new Random();

 int x = r.Next(1, 64);
                Console.WriteLine(x);
                int b = 2;
                string binValue = Convert.ToString(x, B)/>;
                Console.Write("bin: " + binValue.ToString());
                string[] a = new string[binValue.Length];
                
                    for (int i = 0; i < binValue.Length; i++)
                    {
                        a[i] = binValue.Substring(i, 1);
                        Console.WriteLine(a[i]);

                    }




i used substring method to split the string into the array but it didn't display the first and last values so i don't know why??

can anyone help????

Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>