System.Xml.Xsl.XsltOld.NumberAction.NumberingFormat.ConvertToArabic C# (CSharp) Method

ConvertToArabic() static private method

static private ConvertToArabic ( double val, int minLength, int groupSize, string groupSeparator ) : string
val double
minLength int
groupSize int
groupSeparator string
return string
            static string ConvertToArabic(double val, int minLength, int groupSize, string groupSeparator) {
                String str;

                if (groupSize != 0 && groupSeparator != null ) {
                    NumberFormatInfo NumberFormat = new NumberFormatInfo();
                    NumberFormat.NumberGroupSizes = new int[] { groupSize };
                    NumberFormat.NumberGroupSeparator = groupSeparator;
                    if (Math.Floor(val) == val) {
                        NumberFormat.NumberDecimalDigits = 0;
                    }
                    str = val.ToString("N", NumberFormat);
                }
                else {
                    str = Convert.ToString(val, CultureInfo.InvariantCulture);
                }

                if (str.Length >= minLength) {
                    return str;
                } else {
                    StringBuilder sb = new StringBuilder(minLength);
                    sb.Append('0', minLength - str.Length);
                    sb.Append(str);
                    return sb.ToString();
                }
            }
        }