Skip to main content
AI Assist is now on Stack Overflow. Start a chat to get instant answers from across the network. Sign up to save and share your chats.
edited tags
Link
rohancragg
  • 5.2k
  • 5
  • 39
  • 47
Source Link
Prasad
  • 59.6k
  • 65
  • 154
  • 202

convert comma separated string to list using linq

I have 3 comma separated strings FirstName, MiddleInitial, LastName

I have a class NameDetails:

public class NameDetails { public string FirstName { get; set; } public string MiddleInitial { get; set; } public string LastName { get; set; } } 

I have the values for strings as:

FirstName ="John1, John2, John3" MiddleInitial = "K1, K2, K3" LastName = "Kenndey1, Kenndey2, Kenndey3" 

I need to fill the NameDetails List with the values from the comma separated strings.

Any linq for this? I need this for my asp.net mvc (C#) application.