BF2Statistics.StringExtensions.SplitBySize C# (CSharp) Method

SplitBySize() public static method

Returns an Enumeration of this string, split by the specified size
public static SplitBySize ( this str, int chunkSize ) : IEnumerable
str this
chunkSize int The size of each chunk, in which this string is split by
return IEnumerable
        public static IEnumerable<string> SplitBySize(this string str, int chunkSize)
        {
            if (chunkSize < 1)
                throw new ArgumentException("Split size cannot be less then 1", "chunkSize");

            return Enumerable.Range(0, (int)Math.Ceiling(str.Length / (double)chunkSize)).Select(i => str.Substring(i * chunkSize, chunkSize));
        }