-1

I want output like this in the C#. I really want to know. please

int a = 12345;
int[] B = new int[5];

I want output Like:

0 : 1;
1 : 2;
2 : 3; 
3 : 4;
4 : 5;
Tom Fuller
  • 5,291
  • 7
  • 33
  • 42
Shaurya Srivastava
  • 133
  • 1
  • 1
  • 8

1 Answers1

0

you could use:

int a = 12345;
int[] B = a.ToString().ToCharArray().Select(ch => Convert.ToInt32(ch.ToString())).ToArray();

or

int a = 12345;
int[] B = a.ToString().ToCharArray().Select(ch => int.Parse(ch.ToString())).ToArray();
user3598756
  • 28,893
  • 4
  • 18
  • 28