I have a program which returns system.collections.generic.list 1 system.object
I have tried several times to return the actual value of this parameter and to change it according to what I found in google but it does not work for me.
What I'm trying to do is use Linq to get the value of a list:
Response[] resp = db.GetResponse();
for (int i = 0; i < resp.Length; ++i)
{
int userIDindex = -1;
int fnIndex = -1;
int lnIndex = -1;
if (resp.Length > 0)
{
// the first record contains the names of the fields
for (int j = 0; j < resp[i].List.Length; j++)
{
if (resp[i].List[j].ToString() == "Q9Row1")
userIDindex = j;
else if (resp[0].List[j].ToString() == "SubjectID")
lnIndex = j;
}
if (userIDindex >= 0)
{
for (int k = 1; k < resp.Length; k++)
{
var userData = resp[k].List;
List<string> toEmailAdresses = new List<string>();
string fromEmailAddress = "";
string bodyMessage = "";
List<string> projectId = new List<string>();
int count = xml.GetElementsByTagName("toEmailAdresses").Count;
for (int t = 0; t < count; ++t)
{
{
while ((userData[userIDindex].ToString().Equals("3", StringComparison.CurrentCultureIgnoreCase) ||
userData[userIDindex].ToString().Equals("4", StringComparison.CurrentCultureIgnoreCase))) //&&
{
if (userData[userIDindex].ToString().Equals("3", StringComparison.CurrentCultureIgnoreCase) ||
userData[userIDindex].ToString().Equals("4", StringComparison.CurrentCultureIgnoreCase))
{
toEmailAdresses.Add(xml.GetElementsByTagName("toEmailAdresses")[t].InnerText);
bodyMessage = xml.GetElementsByTagName("bodyMessage").ToString();
MailMessage mail = new MailMessage("[email protected]", toEmailAdresses[t].ToString());
SmtpClient client = new SmtpClient();
client.Port = 25;
client.DeliveryMethod = SmtpDeliveryMethod.Network;
client.UseDefaultCredentials = false;
client.Host = "localhost"; //here goes the smpt connection
mail.Subject = "Testing email";
mail.Body = bodyMessage[t] + "___" + userData[lnIndex].ToString().Select(r => r.ToString() == "SubjectID").ToList();
client.Send(mail);
}
}
}
}
}
}
}
}
This is what I get from the resp list:
<Response>
<List>
<anyType xsi:type="xsd:string">Q9Row1</anyType>
<anyType xsi:type="xsd:string">Q9Comment1</anyType>
<anyType xsi:type="xsd:string">Q10Row1</anyType>
<anyType xsi:type="xsd:string">Q10Comment1</anyType>
<anyType xsi:type="xsd:string">Q11Row1</anyType>
<anyType xsi:type="xsd:string">SubjectID</anyType>
</List>
</Response>
<Response>
<List>
<anyType xsi:type="xsd:string">1</anyType>
<anyType xsi:type="xsd:string">2</anyType>
<anyType xsi:type="xsd:string">2</anyType>
<anyType xsi:type="xsd:string">1</anyType>
<anyType xsi:type="xsd:string">1</anyType>
<anyType xsi:type="xsd:string">user1</anyType>
</List>
</Response>
What I'm looking for is the value of SubjectID from the list.
How can I achieve this?
Thanks in advance