this is my code,its shows an error in this line public static string NumberToWords(int num)
"not all code paths return a value"
pls help me..
this is my code
public partial class NumbertoTExt : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
int num = 1234;
NumberToWords(num );
}
public static string NumberToWords(int num)
{
if (num < 0)
return "Minus " + NumberToWords(-num);
else if (num == 0)
return "";
else if (num <= 19)
return new string[] { "One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten", "Eleven", "Twelve", "Thirteen", "Fourteen", "Fifteen", "Sixteen", "Seventeen", "Eighteen", "Nineteen" }[num - 1] + " ";
else if (num <= 99)
return new string[] {"Twenty", "Thirty", "Forty", "Fifty", "Sixty", "Seventy",
"Eighty", "Ninety"}[num / 10 - 2] + " " + NumberToWords(num % 10);
else if (num <= 199)
return "One Hundred " + NumberToWords(num % 100);
else if (num <= 999)
return NumberToWords(num / 100) + "Hundreds " + NumberToWords(num % 100);
else if (num <= 1999)
return "One Thousand " + NumberToWords(num % 1000);
else if (num <= 999999)
return NumberToWords(num / 1000) + "Thousands " + NumberToWords(num % 1000);
else if (num <= 1999999)
return "One Million " + NumberToWords(num % 1000000);
}
}