I have a class like so:
public class OverDueClass
{
public int CustomerID { get; set; }
public int Question_ID { get; set; }
public string Department { get; set; }
public DateTime DueDate { get; set; }
}
And I am populating this class and passing it to another method:
while (dataReader.Read())
{
OverDueClass overDueItem = new OverDueClass();
overDueItem.CustomerID = (int)dataReader[0];
overDueItem.Question_ID = (int)dataReader[1];
overDueItem.Department = dataReader[2].ToString();
overDueItem.DueDate = (DateTime)dataReader[3];
OverDueCell.Add(overDueItem);
}
sendEmail("[email protected]", OverDueCell);
Now in the other method, I can see the data is being passed.
Now I am trying to run a foreach to do something with the data and I tried the following:
foreach(string item in overDue)
{
}
But I get this error:
Cannot covert type to string.
overDueI'm assuming is a singleOverDueClass, its not an array or collection, so you can'tforeachover it. Are you trying to iterate through all the properties in the class?OverDueCellas a parameter tosendEmailmethod, I thinkoverDuewould beOverDueCell.