المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : Change A Property Within The Foreach Loop



C# Programming
02-08-2010, 12:00 AM
Is it ok in .Net 3.5 to change a property within a foreach loop? Does it still run the risk of producing unpredictable results? Also, will the potential results be noticeable or might it cause some type of slow, inconspicuous but nonetheless catastrophic error.

For example:

foreach(Employee janitor in EmployeesWithPayIncrease)
{
janitor.Salary += 5000;
}

Thanks for any help or information you can provide.