﻿# V3005\. The 'x' variable is assigned to itself\.

Анализатор обнаружил потенциальную ошибку, связанную с тем, что значение переменной присваивается само себе\.

Рассмотрим пример, взятый из реального приложения:

```cpp
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;
}
```

Из кода видно, что программист хотел изменить значения свойств объекта в соответствии с принятыми в методе параметрами, но ошибся и присвоил свойству `QuestionId` его собственное значение вместо значения аргумента `questionId`\. 

Корректный код должен выглядеть так:

```cpp
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;
}
```