Named groups make sense, if you want to refer to some of them further on in your pattern. Why not simply create a new Class Product with the three properties you need (e.g. PID, PName, PPrice) and then you could do something like below, based on my proposal above:
List<Product> productList = new List<Product>();
foreach (var item in lst) {
string[] arr = item.Split(',');
productList.Add(new Product {
PID = arr[0],
PName = arr[1],
PPrice = arr[2]
});
}
No comments:
Post a Comment