29 lines
760 B
C#
29 lines
760 B
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Tor
|
|
{
|
|
public class Utility
|
|
{
|
|
private Utility()
|
|
{
|
|
}
|
|
public static String FormatNumber(double number,int places,bool commas=false)
|
|
{
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
StringBuilder formatString=new StringBuilder();
|
|
if (commas&&number>=1000.00) formatString.Append("{0:0,0.");
|
|
else formatString.Append("{0:0.");
|
|
for(int index=0;index<places;index++)formatString.Append("0");
|
|
formatString.Append("}");
|
|
if (double.NaN.Equals(number)) sb.Append("N/A");
|
|
else sb.Append(String.Format(formatString.ToString(), number));
|
|
return sb.ToString();
|
|
}
|
|
}
|
|
}
|