TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Ajay Mavatkar
NA
68
12.6k
find same words in string expression
Jun 5 2017 6:24 AM
I have a expression like as follows,
(Age = 20 and Age = 30 and Age = 40)
I want to convert the above expression as
Age IN (20,30,40)
Can any help?
Reply
Answers (
4
)
1
Amit Gupta
0
22.9k
242.5k
Jun 5 2017 12:28 PM
Use Replace function to generate your desired output
string
age =
"(Age = 20 and Age = 30 and Age = 40)"
;
var value =
"Age in"
+ age.Replace(
"Age"
,
""
).Replace(
"="
,
""
).Trim().Replace(
"and"
,
","
).Trim();
Isnt simple?
Accepted Answer
0
Vivek Kumar
156
11.8k
5.6m
Jun 5 2017 8:43 AM
Are you using c#? Can you wite your sample code?
0
Ajay Mavatkar
0
68
12.6k
Jun 5 2017 8:41 AM
Actually the string expression
(Age = 20 and Age = 30 and Age = 40) needs to be converted to
Age IN (20,30,40) to execute query. The above expression is stored in a string variable
0
Vivek Kumar
156
11.8k
5.6m
Jun 5 2017 8:24 AM
what do you want ? Can you elaborate your question?
How to pass table name dynamically in entity framework mvc5
How to create a multi-item selection combobox in csharp