Reputation: 21
I have a arrayA
var arrayA = ["1111|0000-01-30|123456|CUSTOMER", "1111|0000-01-30|123457|CUSTOMER", "1111|0000-01-30|123458|CUSTOMER"];
How can i slipt "|" to array B
var arrayB= ["123456","123457","123458"]
How can i do? I don't want to use for loop.
Upvotes: 0
Views: 64
Reputation: 56423
Use Select
to transform each splitted string into its third element and collect to an array:
arrayA.Select(s => s.Split('|')[2]).ToArray();
using System.Linq;
required.
Upvotes: 3