开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜