Click here to Skip to main content
15,912,504 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have a database which saves user conditions in table and based on that conditions discount is provided.

i have saved data and retirived data from database, and saved this data as string in program .
Now problem is i want to convert this string in boolean format, I have used Convert.toBoolean which throws "string was not recognized as valid boolean expression"
then i have used Boolean.TryParse but it always returns false.
For condition,
61.39>50 && 61.39<70, it returns false but is true.

Can any one provide solution for this??
Thank You
Posted
Comments
Sergey Alexandrovich Kryukov 21-Jan-13 0:10am    
How come you don't show the content of you string on input? Or course, it can be anything and fail the parsing...
—SA
Hetal Jariwala 21-Jan-13 0:18am    
i have simply write 61.39>50 && 61.39<70 string in Boolean.TryParse but still it returns false
Sergey Alexandrovich Kryukov 21-Jan-13 1:03am    
I see. It is not curable. All wrong, period. You cannot to it at all. Shows total misunderstanding on what a program does, what is code, what is compilation, etc. The only thing is can do is to forget everything you learned about computers and start over... Honestly.
—SA
Hetal Jariwala 21-Jan-13 0:14am    
i have simply write 61.39>50 && 61.39<70 string in Boolean.TryParse but still it returns false
Jibesh 21-Jan-13 0:18am    
you need to store the result of this expression into a bool variable. I believe tryparse wont execute the expression it just try to convert the string literals to a boolean variable true/false it wont work as you expected you need to rethink about your implementation here

I have no idea why would you need to parse Boolean from string, but you can use bool.Parse or bool.TryParse, but check up your spelling. It should be capitalized "True" or "False".

[EDIT]

Did you try to write something like bool.Parse("61.39>50 && 61.39<70")? Only honestly. :-)

OK, I see. No, this is total gibberish. I'm too shocked to explain why, sorry.

—SA
 
Share this answer
 
v3
Comments
Hetal Jariwala 21-Jan-13 0:22am    
I have tried it but still not working
Sergey Alexandrovich Kryukov 21-Jan-13 0:55am    
What do you mean by that, exactly?! (see my update, after [EDIT])
—SA
SoMad 21-Jan-13 1:03am    
Your latest edit is how I understand the comments following the question.

Soren Madsen
Sergey Alexandrovich Kryukov 21-Jan-13 1:05am    
I see. Updated my post. This is beyond good and evil. I don't have guts to explain why it's wrong, do you? :-)
—SA
SoMad 21-Jan-13 1:12am    
I might, but I think if OP follows the first link in Solution 2 and reads it thoroughly, that might be the best way to understand and learn from this.

Soren Madsen

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900