Everyone Is An Achiever

Tuesday, December 30, 2014

[improved] Convert a whole integer to an array of integers

9:50 AM Posted by Unknown No comments
the class takes string  and returns byte of integers

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace TectConsole
{
   class ConvertToIntegers
    {
        private byte[] numbers { get; set; }

        public byte[] doConvert(string strNumber)
        {
            numbers = new byte[strNumber.Length];
            for (int i = 0; i < numbers.Length; i++)
                numbers[i] = (byte)(strNumber[i] - '0');

            return numbers;
        }
    }
}

0 comments:

Post a Comment