I have made an array that take an input say “12345” and splits it down into the following
0 – 1
1 – 2
2 – 3
3 – 4
4 – 5
I then shuffle these numbers up a little to get
0 – 5
1 – 2
2 – 3
3 – 4
4 – 1
Once this is done i want to return the take this array and create an int of the new order , so the output i want is “52341”
I though i had solved this up I an the following error when I run my code ‘Input string was not in a correct format.’
So here is my code and can anyone help?
C#
string result = number[i].ToString();
var intList = result.Select(digit => Int64.Parse(digit.ToString()));
Int64[] Circle = intList.ToArray();
int order = Circle.Length;
int check = 0;
while (check < order)
{
numholder = Circle[0];
Array.Copy(Circle, 1, Circle, 0, Circle.Length - 1);
Circle[order - 1] = numholder;
//string p = Circle.ToString();
//string p = Circle.ToString();
Int64 h = Int64.Parse(Circle.ToString());
I think your problem is in this line:
This is because
Circle.ToString()returnsInt64[], and this isn’t the correctInt64I think you should use this line with
String.Join: