| |

VerySource

 Forgot password?
 Register
Search
View: 3832|Reply: 25

How to apply strings and the "||" operator

[Copy link]

2

Threads

6

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 China

Post time: 2020-3-14 11:00:01
| Show all posts |Read mode
string zxs = ob.scr (sql, "shuju");
        if (zxs == "Beijing" || zxs == "Shanghai" || zxs == "Tianjin" || zxs == "Chongqing")
        {
            return true;
        }
        else
        {
            return false;
        }
An error is reported that bool and string cannot be applied
What should I write?
Reply

Use magic Report

0

Threads

20

Posts

15.00

Credits

Newbie

Rank: 1

Credits
15.00

 LAN

Post time: 2020-6-10 21:45:02
| Show all posts
if ((zxs=="Beijing" )(|| zxs=="Shanghai")( || zxs=="Tianjin" )(|| zxs=="Chongqing"))
...
Reply

Use magic Report

0

Threads

20

Posts

15.00

Credits

Newbie

Rank: 1

Credits
15.00

 LAN

Post time: 2020-6-10 23:15:01
| Show all posts
if ((zxs=="Beijing" )||( zxs=="Shanghai")||( zxs=="Tianjin")||( zxs=="Chongqing"))
A BOOL is best enclosed in ()
Reply

Use magic Report

1

Threads

11

Posts

11.00

Credits

Newbie

Rank: 1

Credits
11.00

 China

Post time: 2020-6-10 23:30:01
| Show all posts
You won't add more ()
Reply

Use magic Report

0

Threads

20

Posts

15.00

Credits

Newbie

Rank: 1

Credits
15.00

 LAN

Post time: 2020-6-11 06:30:01
| Show all posts
((zxs=="Beijing" )||( zxs=="Shanghai")||( zxs=="Tianjin")||( zxs=="Chongqing"))
//I didn’t believe it, I didn’t write it right.
Reply

Use magic Report

0

Threads

52

Posts

34.00

Credits

Newbie

Rank: 1

Credits
34.00

 China

Post time: 2020-6-11 09:45:01
| Show all posts
The code is full, so you can’t see anything.
What is ob.scr(sql, "shuju")
Reply

Use magic Report

0

Threads

64

Posts

45.00

Credits

Newbie

Rank: 1

Credits
45.00

 China

Post time: 2020-6-11 12:15:01
| Show all posts
The method written in this code to see if the return value type is inconsistent
What you are returning now is the Bool value
Reply

Use magic Report

1

Threads

7

Posts

8.00

Credits

Newbie

Rank: 1

Credits
8.00

 China

Post time: 2020-6-11 12:45:01
| Show all posts
No parentheses are required.
The landlord's writing is correct, it should be something else, such as zxs, whether the punctuation is correct
Reply

Use magic Report

0

Threads

17

Posts

14.00

Credits

Newbie

Rank: 1

Credits
14.00

 China

Post time: 2020-6-11 17:45:02
| Show all posts
The posted code is correct.
Reply

Use magic Report

0

Threads

52

Posts

34.00

Credits

Newbie

Rank: 1

Credits
34.00

 China

Post time: 2020-6-11 19:00:01
| Show all posts
What does ob.scr(sql, "shuju") return?
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list