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
Rakib Ahmed
NA
61
5.5k
String Split from one line text
Jul 8 2020 5:40 AM
I have a string like
String OrderText = @"1 MI-SCBSMT24SM 10 45.62 1 PC 456.20 2020.03.18
MI-SCBSMT24SM,, MI-SCBSMT24SM
2 MI-SCBSML24SM 10 32.28 1 PC 322.80 2020.03.18
MI-SCBSML24SM,, MI-SCBSML24SM"
Here one order is 1 MI-SCBSMT24SM 10 45.62 1 PC 456.20 2020.03.18 MI-SCBSMT24SM,, MI-SCBSMT24SM
And second order is
2 MI-SCBSML24SM 10 32.28 1 PC 322.80 2020.03.18 MI-SCBSML24SM,, MI-SCBSML24SM
It can be consist of 3 rows
what i wanted to do split by each of order
my output will be like
orderRow.ArticleCode = OrderItem[1];
// MI-SCBSMT24SM
orderRow.Quantity = Convert.ToInt32(OrderItem[2]);
// 10
orderRow.Price = OrderItem[3];
// 45.62
orderRow.Amount = OrderItem[6];
// 456.20
orderRow.DeliveryDate = OrderItem[7].Replace(
"."
,
"-"
);
// 2020.03.18
and for second orderrow
orderRow.ArticleCode = OrderItem[1];
// MI-SCBSML24SM
orderRow.Quantity = Convert.ToInt32(OrderItem[2]);
// 10
orderRow.Price = OrderItem[3];
// 32.28
orderRow.Amount = OrderItem[6];
// 322.80
orderRow.DeliveryDate = OrderItem[7].Replace(
"."
,
"-"
);
// 2020.03.18
3rd row i mean that there can be another row like below way
3 MI-SCBSML24SM 10 32.28 1 PC 322.80 2020.03.18
MI-SCBSML24SM,, MI-SCBSML24SM
we have to do the same
orderRow.ArticleCode = OrderItem[1];
// MI-SCBSML24SM
orderRow.Quantity = Convert.ToInt32(OrderItem[2]);
// 10
orderRow.Price = OrderItem[3];
// 32.28
orderRow.Amount = OrderItem[6];
// 322.80
orderRow.DeliveryDate = OrderItem[7].Replace(
"."
,
"-"
);
// 2020.03.18
Reply
Answers (
3
)
Calculate the marks and gets its averages marks
An item with the same key has already been added.