Formatting a number
-
is it possible to format the number 150000 to 1,50,000. I tried formatting using DataformatString but, it displays 150,000. Do anyone know how to format a number to indian currency. N.Surendra Prasad
-
is it possible to format the number 150000 to 1,50,000. I tried formatting using DataformatString but, it displays 150,000. Do anyone know how to format a number to indian currency. N.Surendra Prasad
U need to count number of digits and place the , accordingly There may be other alternatives .. for a quick fix try the above
If You win You need not Explain............ But If You Loose You Should not be there to Explain......
-
is it possible to format the number 150000 to 1,50,000. I tried formatting using DataformatString but, it displays 150,000. Do anyone know how to format a number to indian currency. N.Surendra Prasad
-
Do you have any sample on how to use this?
-
Do you have any sample on how to use this?
-
Do you have any sample on how to use this?
Having looked in more detail I think that thread is a little over-complicated. Why not use the CultureInfo class? If you're going to be using it alot it could be useful to set it as an extension method something like this.
using System.Globalization;
namespace Indian
{
public static class ExtMethods
{
public static string ToIndian(this double amount, bool includePrefix)
{
CultureInfo indianCulture = new CultureInfo("hi-IN");
string indianString = amount.ToString("C", indianCulture);
if (includePrefix)
{
return indianString;
}
return indianString.Substring(2);
}
}
}then add
using Indian;
to the beginning of any class that needs it. You can then easily call the method on any double value (change it to other value type if required!).double doubleIndian = 1234567.89;
string stringIndian = doubleIndian.ToIndian(false);Dave