Exploration and learning of for and foreach in C#

Insert image description here
1: Statements and expression methods
for statement:

for(初始表达式;条件表达式;增量表达式)
{
   
    
    
     循环体
}

foreach statement:

foreach(数据类型 变量 in 数组或集合)
{
   
    
    
     循环体
}

understand

1. From the perspective of program logic, foreach is implemented through pointer offset (initially at the -1 position, and the pointer becomes cheaper by one unit each time it loops), while the for loop is implemented by

Guess you like

Origin blog.csdn.net/weixin_44301520/article/details/133400025