|
-
June 12th, 2008, 12:55 AM
#1
please check the format
Code:
if (!(GetField(header, fields, "Declared Value for Carriage").Equals("") || GetField(header, fields, "Declared Value for Carriage").Equals(null)) && !(GetField(header, fields, "Number of Packages").Equals("") || GetField(header, fields, "Number of Packages").Equals(null)))
{
writer.WriteElementString("InsuranceAmount", (int.Parse(GetField(header, fields, "Declared Value for Carriage")) / int.Parse(GetField(header, fields, "Number of Packages"))).ToString());
//writer.WriteElementString("InsuranceAmount", "");
}
else
{
writer.WriteElementString("InsuranceAmount", "");
//writer.WriteElementString("InsuranceAmount", (Convert.ToInt16(GetField(header, fields, "Declared Value for Carriage")) / Convert.ToInt16(GetField(header, fields, "Number of Packages"))).ToString());
}
i m getting error in the third line .the error states that the input string format is not correct.please help me............
Last edited by cilu; June 12th, 2008 at 01:16 AM.
-
June 12th, 2008, 01:17 AM
#2
Re: please check the format
I cannot follow your code. What about reorganizing a little it. Introducing some variables to simplify it?
-
June 12th, 2008, 08:52 AM
#3
Re: please check the format
Code:
int declaredValue = int.Parse(GetField(header, fields, "Declared Value for Carriage"));
int packageNumber = int.Parse(GetField(header, fields, "Number of Packages"));
writer.WriteElementString("InsuranceAmount", Convert.ToString(declaredValue / packageNumber));
Make it cleaner...
Last edited by yraen; June 12th, 2008 at 08:58 AM.
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
|