Why do I get the following warning in my C# code?
the private field xxxx is assigned but its value is never used
The attribute in question is only used as a flag for the user. Indeed the user can access (get) the value false
or true
to know a state of something.
Here is an example of code which creates this warning:
class Class1 {
// Attributes
private b_myboolean = false;
// Accessors
public bool B_myboolean
{
get{ return b_myboolean;}
}
// Methods
// Somewhere in a method
b_myboolean =true;
}
Something like that will return the warning. Why? Do I have to code this flag another way?