Skip to content

Latest commit

 

History

History
40 lines (31 loc) · 1.11 KB

cs1717.md

File metadata and controls

40 lines (31 loc) · 1.11 KB
description title ms.date f1_keywords helpviewer_keywords ms.assetid
Learn more about: Compiler Warning (level 3) CS1717
Compiler Warning (level 3) CS1717
07/20/2015
CS1717
CS1717
5b150a2c-5d61-4cd8-b4d4-e6c2b93b52c6

Compiler Warning (level 3) CS1717

Assignment made to same variable; did you mean to assign something else?

This warning occurs when you assign a variable to itself, such as a = a.

Several common mistakes can generate this warning:

  • Writing a = a as the condition of an if statement, such as if (a = a). You probably meant to say if (a == a), which is always true, so you could write this more concisely as if (true).

  • Mistyping. You probably meant to say a = b.

  • In a constructor where the parameter has the same name as the field, not using the this keyword: you probably meant to say this.a = a.

Example

The following sample generates CS1717.

// CS1717.cs  
// compile with: /W:3  
public class Test  
{  
   public static void Main()  
   {  
      int x = 0;  
      x = x;   // CS1717  
   }  
}