Accord.Math.MatrixFormatter.handleOtherFormats C# (CSharp) Method

handleOtherFormats() private static method

Handles formatting for objects other than matrices.
private static handleOtherFormats ( string format, object arg, IFormatProvider culture ) : string
format string
arg object
culture IFormatProvider
return string
        private static string handleOtherFormats(string format, object arg, IFormatProvider culture)
        {
            try
            {
                IFormattable obj = arg as IFormattable;
                if (obj != null)
                {
                    return obj.ToString(format, culture);
                }
                else if (arg != null)
                {
                    return arg.ToString();
                }
            }
            catch (FormatException e)
            {
                throw new FormatException(String.Format("The format of '{0}' is invalid.", format), e);
            }

            return String.Empty;
        }