Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public int[] RemoveCommasFromStringOfNumbers(string numbersAndCommas) {
- int[] numbers = new int[6]
- int x = 0;
- string tempNumber;
- if (numbersAndCommas.Length != 0) {
- for (int i = 0; i < numbersAndCommas.Length; i++) {
- if (numbersAndCommas[i].isDigit) { // if char is a digit
- tempNumber += numbersAndCommas[i];
- } else { // else push to numbers array, because we hit a comma
- if (x < 6) {
- numbers[x] = Int32.Parse(tempNumber)
- x++;
- tempNumber = "";
- }
- }
- }
- }
- return numbers;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement