Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Int number to String Array
//Title of this code //Rextester.Program.Main is the entry point for your code. Don't change it. //Compiler version 4.0.30319.17929 for Microsoft (R) .NET Framework 4.5 using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; namespace Rextester { public class Program { public static void Main(string[] args) { int number = 1234; int length = 4; //type the length of the number here, e.g. 4 digits. int[] num = new int[length]; string[] stringNum = new string[length]; stringNum = ReturnStringArray(number, num, length); } public static string[] ReturnStringArray(int number, int[] num, int length) { num = ReverseOrder(number, length); //creates an array with all digits in a string format string[] stringNum = new string[length]; stringNum = StringArray(num, length); return stringNum; } public static int[] ReverseOrder(int number, int length) { int[] num = new int[length]; for (int i = 0; i<length; i++) { num[i] = (number % 10); number = (number/10); } //Shows all digits /*foreach (int numbers in num) { Console.WriteLine(numbers); }*/ return num; } public static string[] StringArray(int[] num, int length) { string[] stringNum = new string[length]; for (int i = 0; i < num.Length; i++) { stringNum[i] = num[i].ToString(); } return stringNum; } } }
run
|
edit
|
history
|
help
0
OBJ Good Start
Hi
work_laba#2
Main 5.6
C# interview question. Closure pitfalls.
LevenshteinDistance
Simple inheritance
Convert String to Pig Latin
Generics Operator test
Hello-Newark-World