is wrong ban an enumerator child category an enumerator progenitor class?
i've got an blunder build says:
error 12 can't many convert
type
'system.collections.generic.ienumerator< baseclass>'
to
'system.collections.generic.ienumerator< iparentclass>'.
an eloquent reworking exists (are you
blank cast?)
is wrong simply ban away?
this code:
public dictionary<int32, baseclass> map { get; private set; }
public ienumerator<baseclass> getenumerator()
{
relapse this.map.values.getenumerator();
}
public ienumerator<iparentclass> ienumerable<iparentclass>.getenumerator()
{
relapse this.getenumerator(); // error!
}
my doubt is, i only change line:
return this.getenumerator();
to:
return (ienumerator<iparentclass>)this.getenumerator();
(without any bad side effects)?
accepted answer:
i've altered duty following (after reading jon skeet's post):
ienumerator<iparentclass> ienumerable<iparentclass>.getenumerator()
{
relapse this.map.values.cast<iparentclass>().getenumerator();
}
Comments
Post a Comment