Specified cast is not valid?

This is my statement:  
if ((byte)data["TranC"] == 'A')

Open in new window

The field is defined as "char" in a Firebird table. How should I cast this?
Who is Participating?
p_davisConnect With a Mentor Commented:
a char is actually an int if you wanted to tho' you could data["TranC"].ToString() == "A";
rmmarshAuthor Commented:
I did it without the cast, and I did it with the "int" cast... either way, I get the error "Specified cast is not valid".

And then I did this:  if (int.Parse(data["TranC"].ToString()) == 'A')

and the CLR tells me the input string was not in the correct format!

Any other suggestions?
did you try the

data["TranC"].ToString() == "A";//?
rmmarshAuthor Commented:
I'm going to give you the points because you were very close... this is what I wound up doing:

 shipping = uint.Parse(data["Shipping"].ToString());

And it appears to be working... thank you for the time...
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.