user8507737
user8507737

Reputation:

The variable declared but value is never used error

I searched in SO and found some similar questions, but they did not solve my problem.

I am using ASP.Net and here is my code :

 protected void Page_Load(object sender, EventArgs e)
 {
    if (!IsPostBack)
    {
     int _new = 0;
     // other lines of codes which does not include _new

     for (int i = 0; i < _Array.Length; i++)
         {
            if (_Array[i] == "N" || _Array[i] == "NEW")
            {
                _new = 1;
            }
     }

     // other lines of codes which does not include _new
}
 }

I get the The variable declared but value is never used error warning on

 int _new = 0;

why I am getting this error?

Upvotes: 0

Views: 42

Answers (1)

Shrad_k
Shrad_k

Reputation: 86

Because you have not done any process on the variable _new, you are only assigning the value to it

Upvotes: 1

Related Questions