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
Jenith ThakkarPosted Jul 9, 2020, 4:26 AM
First concate string with any seprator like pipe
So string will be like
Then you can First split it with Pipe '|'
var arr = OrderText.split("|");
Now split that array with space
For(i=0;i<...){
var arr1 = arr[i].split(' ');
}
Thank you
Laxmidhar SahooPosted Jul 9, 2020, 3:13 AM
Rajanikant HawaldarPosted Jul 8, 2020, 5:50 AM