I want to copy data from one list to another list. While copying to the new list, i want to assign new values also. Can someone please assist quickly. I want to achieve something like below,
public HashSet<string> MobileNumber { get; set; }
var contactViewData = MobileNumber.Select(p => p).SelectMany(o => o.SplitFromCsv()).Select(x => new ContactViewMap()
{
ContactId = Guid.NewGuid().ToString(),
NewMobileNumber = x,
OldMobileNumber = p
}).ToList();
public class ContactViewMap
{
public string ContactId { get; set; }
public string NewMobileNumber { get; set; }
public string OldMobileNumber { get; set; }
}
public static IEnumerable<string> SplitFromCsv(this string csv)
=> csv.Split(',', StringSplitOptions.None);
Input:
{
"MobileNumber": [
"+9112352",
"+9112353"
]
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…