title: Converting numbers with decimals to text
body: <p>I'm trying to convert numbers to text and this code gives me an error at one of the variables. </p>
  
  <p>Just at the end of the third variable it gives me an "; expected" error. </p>
  
  <p>What's going on in the code?</p>
  
  <pre><code>public static string NumberToWords(double doubleNumber)
      {
          var beforeFloatingPoint = (int)Math.Floor(doubleNumber);
          var beforeFloatingPointWord = "{NumberToWords(beforeFloatingPoint)} Rupees";
          var afterFloatingPointWord = "{SmallNumberToWord((int) ((doubleNumber - beforeFloatingPoint) * 100),"")} cents";
          return "{beforeFloatingPointWord} and {afterFloatingPointWord}";
      }
  </code></pre>
  
  <p>the error is exactly at the end of the below line. </p>
  
  <pre><code>var afterFloatingPointWord = "{SmallNumberToWord((int) ((doubleNumber - beforeFloatingPoint) * 100),"")} cents";
  </code></pre>
  
  <p>full code is below and now when I run the code I get an error saying input string was not in a correct format (at the button click event). it works without decimal. but with decimal it gives me this error. I'm posting the full code below.</p>
  
  <p>if someone can help me to get this working please.</p>
  
  <pre><code>    using System;
  using System.Collections.Generic;
  using System.ComponentModel;
  using System.Data;
  using System.Drawing;
  using System.Linq;
  using System.Text;
  using System.Threading.Tasks;
  using System.Windows.Forms;
  
  namespace CheckPrintingSystem
  {
      public partial class Form1 : Form
      {
          public Form1()
          {
              InitializeComponent();
          }
  
          public static string NumberToWords(double doubleNumber)
          {
              var beforeFloatingPoint = (int)Math.Floor(doubleNumber);
              var beforeFloatingPointWord = string.Format("NumberToWords(beforeFloatingPoint)} Rupees");
              var afterFloatingPointWord = string.Format(@"{SmallNumberToWord((int) ((doubleNumber - beforeFloatingPoint) * 100),"")} cents");
              return "{beforeFloatingPointWord} and {afterFloatingPointWord}";
          }
  
          private static string NumberToWords(int number)
          {
  
  
              if (number == 0) return "zero";
  
              if (number &lt; 0) return "minus" + NumberToWords(Math.Abs(number));
  
              string words = "";
  
              if((number / 1000000) &gt; 0)
              {
                  words += NumberToWords(number / 1000000) + "million ";
                  number %= 1000000;
              }
  
              if((number / 1000) &gt; 0)
              {
                  words += NumberToWords(number / 1000) + "thousand ";
                  number %= 1000;
              }
  
              if ((number / 100) &gt; 0)
              {
                  words += NumberToWords(number / 100) + "hundred ";
                  number %= 100;
              }
  
              words = SmallNumberToWord(number,words);
              return words;
  
          }
  
          private static string SmallNumberToWord(int number, string words)
  
          {
              if (number &lt;= 0) return words;
              if (words != "") words += "and ";
  
                  var unitsMap = new[] { "zero ", "one ", "two ", "three ", "four ", "five ", "six ", "seven ", "eight ", "nine ", "ten ", "eleven ", "twelve ", "thirteen ", "fourteen ", "fifteen ", "sixteen ", "seventeen ", "eighteen ", "nineteen "};
                  var tensMap = new[] { "zero ", "ten ", "twenty ", "thirty ", "fourty ", "fifty ", "sixty ", "seventy ", "eighty ", "ninety " };
                  if (number &lt; 20) words += unitsMap[number];
                  else
                  {
                      words += tensMap[number / 10];
  
                      if ((number % 10) &gt; 0) words += " " + unitsMap[number % 10];
                  }
                  return words;
  
          }
  
  
  
          private void button1_Click(object sender, EventArgs e)
          {
              textBox2.Text = NumberToWords(Convert.ToInt32(textBox1.Text));
          }
      }
  }
  </code></pre>