c# - Why switch inside foreach loop executes only once -
on debugging have condition component.attributes
consists has count =3 (i mean list of 3 elements). , it's inside foreach loop this:
foreach(attributes atrb in component.attributes) { switch (component.type) { case "combo": return validatecombo(atrb); case "list": return validatelist(atrb); default: return true; } } return false;
i observe foreach loop executes first member of list only. please let me know why ddo not execute other list members (i mean @ count 2 , 3) ? due return . how solve ?
return
end of function statement. upon reaching first return
statement, whole function terminated, loop ends immediately.
you typically want use break
statement between different switch cases stop execution continuing until end of switch definition.
Comments
Post a Comment