Ask Learn
Preview
Please sign in to use this experience.
Sign inThis browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Assignment in conditional expression is always constant; did you mean to use == instead of = ?
A conditional expression used the = operator and not the == operator.
The following sample generates CS0665:
// CS0665.cs
// compile with: /W:3
class Test
{
public static void Main()
{
bool i = false;
if (i = true) // CS0665
// try the following line instead
// if (i == true)
{
}
System.Console.WriteLine(i);
}
}
.NET feedback
.NET is an open source project. Select a link to provide feedback:
Please sign in to use this experience.
Sign in