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
darma teja
NA
496
338.5k
get text between two words in a string
Jan 24 2017 7:12 AM
i have string like this:
string myOrder= " \"orderID\":\"123456\",\"orderName\":\"ABC\",\"orderDate\":\"20170120\""
I am trying to get values of orderID, orderName, orderDate by the following method:
List<string> orderName= ExtractFromString(myOrder, "\"orderName\":\"", "\",");
private static List<string> ExtractFromString(string text, string startString, string endString)
{
List<string> matched = new List<string>();
int indexStart = 0, indexEnd = 0;
bool exit = false;
while (!exit)
{
indexStart = text.IndexOf(startString);
indexEnd = text.IndexOf(endString);
if (indexStart != -1 && indexEnd != -1)
{
matched.Add(text.Substring(indexStart + startString.Length,
indexEnd - indexStart - startString.Length));
text = text.Substring(indexEnd + endString.Length);
}
else
exit = true;
}
return matched;
}
I am getting null exception at
matched.add(.
..
Advance thanks,
Darma
Reply
Answers (
3
)
Parallel Robocopy
How to make default value for combobox with selectedvalue=0