Here is some code I have already have which outputs the data :
{ SubjectName = maths, SubjectId = qq1, SubjectValue = 20 }
{ SubjectName = science, SubjectId = sla1s, SubjectValue = 25 }
here is the code which does this:
XElement root = XElement.Load("Data.xml");
var subjects = from subject in root.Descendants()
where subject.Name.LocalName.Contains("Subject")
select new
{
SubjectName = subject.Element("subjectName").Value,
SubjectId = subject.Element("subjectId").Value,
SubjectValue = subject.Element("subjectvalue").Value
};
foreach (var subject in subjects)
{
Console.WriteLine(subject);
string subjectName = subject.SubjectName;
string subjectId = subject.SubjectId;
string subjectValue = subject.SubjectValue;
textBox1.Text = "Subject Name :" + moduleName +
"Subject Id :" + moduleCode +
"Subject Value :" + moduleCredit;
}
My problem is when i try to add the string variable to textBox1 using the code :
textBox1.Text = "Subject Name :" + moduleName + "Subject
Id :" + moduleCode + "Subject Value :" + moduleCredit;
only the second data is displayed which is { SubjectName = science, SubjectId = sla1s, SubjectValue = 25 }
.
How can I make it so that I can store both output in different textfields so that both are displayed.
{ SubjectName = maths, SubjectId = qq1, SubjectValue = 20 }
{ SubjectName = science, SubjectId = sla1s, SubjectValue = 25 }