开发者

what is the difference between these two exection commands in c#

开发者 https://www.devze.com 2023-01-04 22:00 出处:网络
Do you know the difference between these two conditions? 1 if(rea开发者_如何学Goder.hasrows()) { while(reader.read())

Do you know the difference between these two conditions?

1

if(rea开发者_如何学Goder.hasrows())
{
   while(reader.read())
   {

   }
}

2

while(reader.read())
{
   if(reader.hasrows())
   {
   }
}


Doing if/while or while/if is not necessary, since "while(reader.read())" will only return true when the reader has rows "hasrows()" and has a row to read "read()". The extra nesting has no value.

0

精彩评论

暂无评论...
验证码 换一张
取 消