1

https://i.sstatic.net/JGryQ.jpg

   int ctr, len;
    string gee;
    t = kalliskaBillingDataSet.Tables["DealerDetail"];
    len = t.Rows.Count - 1;     
      r = t.Rows[len];
     string id = r["DealerID"].ToString();
     gee = id.Substring(1, 3);
      ctr = int.Parse(gee);

Input string was not in a correct format in the line::

ctr = int.Parse(gee);
1
  • What's the value of "code" after "id.SubString(1,3)"? Did you try to debug it? The exception is thrown because your string "code" cannot be parsed to an int (it may contain letters, weird characters, it's a float, etc...) Commented Oct 26, 2012 at 12:06

2 Answers 2

2

E00 is not a valid decimal string. You need to parse it as though it's a hex string.

Use something like:

int.Parse(code, System.Globalization.NumberStyles.HexNumber);

Of course, it's possible that the value is not supposed to be hexadecimal, in which case you have an error.

To more gracefully recover from such situations, use int.TryParse(code, out value) instead, and check the return value for true/false, indicating success/failure.

Sign up to request clarification or add additional context in comments.

Comments

1

Looking at the screenshot, code was E00, which cannot be converted to an integer.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.