Currenty I am having trouble with something I'm work on. What I want to do is while HasEffect(Buffname) is true I want to return multiple values but one after another but I am unsure how to go about it.
Tldr: I want to return multiple values one after another 1,2,3 without it getting stuck on returning 1st one only.
While(HasEffect(Buffname))
Return Skillname1;
CodePudding user response:
while (HasEffect(Buffname))
{
some logic
yield return Skillname1;
yield return Skillname2;
yield return Skillname3;
yield return Skillname4;
}
The return type of the whole method must be IEnumerable<T> e.g IEnumerable<int>, IEnumerable<string> etc.
Such a method can be used e.g with foreach loop
foreach (var skill in GetAvaliableSkills())
{
// do something with skill
}
