|
-
September 9th, 2010, 02:45 PM
#1
I am getting error like this "System.FormatException was unhandled " Help me
hello friends
I can not convert string to double , I am new to C sharp . Please help me out
I tryed parse,covert, everything . I have pasted the code below .
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class sales
{
double commrate = 0.01;
String andrea;
String emily;
String tom;
double andreaAmount;
double emilyAmount;
double tomAmount;
double amount;
void getSalesName()
{
Console.WriteLine("Enter the sale person name intial and If u want to exit press f");
String s = Console.ReadLine();
if(s.Equals("A")|| s.Equals("B")|| s.Equals("T"))
{
Console.WriteLine("Enter the amount of sales");
Console.ReadLine();
string s1 = Console.ReadLine();
// Error in the below line
amount = double.Parse(s1);
if(s.Equals("A"))
{
andreaAmount = andreaAmount + amount *commrate ;
}
else if(s.Equals("B"))
{
emilyAmount = emilyAmount + amount *commrate;
}
else
{
tomAmount = tomAmount + amount * commrate ;
}
getSalesName();
}
else if(!s.Equals("F"))
{
Console.WriteLine("please reEnter the corrent Intial of the salesPersonName");
Console.Read();
getSalesName();
}
else if(s.Equals("F"))
{
Console.WriteLine("The total sales person sales are");
Console.Write("Andrea " + andreaAmount);
Console.Write("Emily " + emilyAmount);
Console.Write("Tom " + tomAmount);
Console.ReadLine();
}
}
static void Main(string[] args)
{
sales sa = new sales();
sa.getSalesName();
}
}
}
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|