parse a string with name-value pairs

Viewed 32398

How can I parse the following string of name-value pair in C#:

string studentDetail = "StudentId=J1123,FirstName=Jack,LastName=Welch,StudentId=k3342,FirstName=Steve,LastName=Smith"

The purpose of parsing this array is to insert values in DB using Linq to SQL:

[HttpPost]
public ActionResult SaveStudent(string studentDetail)
{
    DataContext db = new DataContext();         

    Student student = new Student();
    {
        student.StudentID = //StudentID
        student.FirstName = //FirstName
        student.LastName = //LastName
    };

    db.Student.InsertOnSubmit(student);
    db.SubmitChanges();

    return View();
}

What is the best way of approaching this?

3 Answers
Related