TVSorter.Model.FileResult.FormatNum C# (CSharp) 메소드

FormatNum() 개인적인 메소드

Format the numbers for output
private FormatNum ( string arg ) : string
arg string /// The variable's argument, the length of the output num ///
리턴 string
        private string FormatNum(string arg, params int[] num)
        {
            if (num.Length == 0)
            {
                throw new ArgumentException("You must specify at least one number to format.");
            }

            int length = int.Parse(arg);

            // Build the format string for the specfied number of digits.
            string zeros = "{0:";
            if (length == 0)
            {
                zeros += "0";
            }
            else
            {
                for (int i = 0; i < length; i++)
                {
                    zeros += "0";
                }
            }

            zeros += "}";

            return num.Distinct().Select(x => string.Format(zeros, x)).Aggregate((x, y) => x + "-" + y);
        }