C# Programming Tutorial 49 - foreach Loop Explained

preview_player
Показать описание


~~~~~~~~~~~~~~~ CONNECT ~~~~~~~~~~~~~~~

~~~~~~~~~~~~~~ SUPPORT ME ~~~~~~~~~~~~~~

🅑 Bitcoin - 3HnF1SWTzo1dCU7RwFLhgk7SYiVfV37Pbq
🅔 Eth - 0x350139af84b60d075a3a0379716040b63f6D3853
Рекомендации по теме
Комментарии
Автор

2.02 IN...a little bit long-winded, I did this inside the foreach loop to output the same result

foreach(int grade in grades)
{
int x = grade;
x*=2;
Console.WriteLine($"Grades = {x}");
}

gamedevrejects
Автор

so the 'grade' is just a placeholder variable for each record in the list? Like I could name it anything I wanted? And is this considered a variable or something else?

nathanielhansel
Автор

Can a for each loop return the element? Foreach (string item in list) {If(some condition) { return item}} for example.

MrFarkasOfficial
Автор

Well done, I found this super useful. Subbed, naturally.

MrFarkasOfficial
Автор

so basically foreach for reading not modyfing elements

mohmedfakhry
Автор

What is the scope of this grade variable? Just within the foreach?

infrared