我有以下代码
int someCount = 0;
for ( int i =0 ; i < intarr.Length;i++ )
{
if ( intarr[i] % 2 == 0 )
{
someCount++;
continue;
}
// Some other logic for those not satisfying the condition
}
Run Code Online (Sandbox Code Playgroud)
是否可以使用Array.Where或Array.SkiplWhile中的任何一个来实现相同的功能?
foreach(int i in intarr.where(<<condtion>> + increment for failures) )
{
// Some other logic for those not satisfying the condition
}
Run Code Online (Sandbox Code Playgroud)