Variable is assigned but its value is never used (C#)

后端 未结 4 1586
一整个雨季
一整个雨季 2020-12-07 06:18

In Visual Studio I used the following code:

 private bool answer = true;
    Private Buttonclick()
   {
      if()
       {
        answer =false
        }
          


        
4条回答
  •  难免孤独
    2020-12-07 07:15

    The reason the warning pops up is not because the variable is never assigned, but because it is in fact never used for any sort of comparison in the rest of the code.

    Please go through this reference: http://weblog.west-wind.com/posts/2009/Feb/28/Variable-is-assigned-but-its-Value-is-never-used-Warning

提交回复
热议问题