-2

how to convert rupees to alphabets asp.net ? I have tried the below code but didn't work. var formatted = d.ToString();

    if (formatted.Contains("."))
    {
        //If it contains a decimal point, split it into both sides of the decimal
        string[] sides = formatted.Split(".");

        //Process each side and append them with "and", "dot" or "point" etc.
        return NumberToWords(Int32.Parse(sides[0])) + " and " + NumberToWords(Int32.Parse(sides[1]));
    }
    else
    {
        //Else process as normal
        return NumberToWords(Convert.ToInt32(d));
    }

Note :I need in the below format

eg :23,234.50 - twenty three thousand two thirty four rupees and 50 paise.

Eliz
  • 7
  • 3
  • 2
    Define "didn't work". Did you remember to implement a method called `NumberToWords` or did you think the compiler was going to do that for you? – David Jun 06 '15 at 10:07

1 Answers1

1

Try this

string amount = "58,765.50";//Here you will replace your value.
amount = amount.Replace(",", "");
string []sides = amount.Split('.');
string rupees = NumberToWords(int.Parse(sides[0])) + " And " + NumberToWords(int.Parse(sides[1])) + " paisa";

Here you will an amount which you want to convert into words. If your amount contains , you need to replace it so that it can be converted into int. You also need to split the amount on . so that you can get rupees and paisa seperate. Than you need to pass rupees and paisa to the function and concatenate them for final output.

Here is the link which you can use for the method NumberToWords

Mairaj Ahmad
  • 14,434
  • 2
  • 26
  • 40