SHARE
TWEET

IntToDigitArray

g-stoyanov Mar 26th, 2014 359 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public static int[] digitArr(int n)
  2. {
  3.     if (n == 0) return new int[1] { 0 };
  4.  
  5.     var digits = new List<int>();
  6.  
  7.     for (; n != 0; n /= 10)
  8.         digits.Add(n % 10);
  9.  
  10.     var arr = digits.ToArray();
  11.     Array.Reverse(arr);
  12.     return arr;
  13. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top