C# foreach 


        for( int i = arrInt.Count - 1; i >=0; i-- )

        {

            int n = ( int ) arrInt[i];

            if( n == 5 )

                arrInt.RemoveAt( i ); // Remove data here

            Debug.WriteLine( n.ToString() );

        }

 

除了这两个地方外,foreach可以基本适用于任何循环,因此对于循环的编写要尽量使用foreach,因为它会使你的代码清晰简洁,又不失高效。

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-21
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-09
  • 2021-08-05
  • 2021-11-02
相关资源
相似解决方案