The analyzer has detected a potential error: a variable is assigned to itself.
The real-world code example:
public GridAnswerData(
int questionId, int answerId, int sectionNumber,
string fieldText, AnswerTypeMode typeMode)
{
this.QuestionId = this.QuestionId;
this.AnswerId = answerId;
this.FieldText = fieldText;
this.TypeMode = typeMode;
this.SectionNumber = sectionNumber;
}
The values of an object's properties are intended to be changed according to the method parameters, but mistakenly assigned its own value to the QuestionId property instead of the questionId argument's value.
The fixed code:
public GridAnswerData(
int questionId, int answerId, int sectionNumber,
string fieldText, AnswerTypeMode typeMode)
{
this.QuestionId = questionId;
this.AnswerId = answerId;
this.FieldText = fieldText;
this.TypeMode = typeMode;
this.SectionNumber = sectionNumber;
}
You can look at examples of errors detected by the V3005 diagnostic. |
Was this page helpful?
Your message has been sent. We will email you at
If you do not see the email in your inbox, please check if it is filtered to one of the following folders:
Take
a chance!