This is just a simple problem that I’m a little stumped on…
As far as I can see I am not actually using a char anywhere as model.children is a IList<> and model.Name is a string however my foreach loop is giving the error that it can’t convert char to catalogue.department, if you need any more information plese feel free to ask.
private void DisplayOnWebsiteChecked(Object sender, EventArgs e)
{
var departments = model.Name;
var departmentChildren = model.Children;
if (departmentChildren != null)
{
int zeroChildren = 0;
if (departmentChildren.Count.Equals(zeroChildren));
{
foreach (Department Children in departments)
{
}
}
}
}
EDIT: This issue has actually be fixed, I will post the fixed code down below as it turns out I actually messed up the code by putting the list in the wrong place.
private void DisplayOnWebsiteChecked(Object sender, EventArgs e)
{
var departments = model.Name;
var departmentChildren = model.Children;
if (departmentChildren != null)
{
int zeroChildren = 0;
if (departmentChildren.Count.Equals(zeroChildren));
{
foreach (Department Child in departmentChildren)
{
}
}
}
}
You have assigned:
here department is of type
stringand string implementsIEnumerable<char>, that is why when you enumerate over it usingforeach, the item in theforeachloop is of typechar.and you are using
Here Children is of type
charsince department is a string, whereas you have specified it to be of typeDepartmentthat is why you are getting this error.