Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All
Expand Minimize

Compiler Warning (level 4) CS0429

Unreachable expression code detected

This error occurs whenever part of an expression in your code is unreachable. In the following example, the condition false && myTest() meets this criteria because the myTest() method will never get evaluated due to the fact that the left side of the && operation is always false. As soon as the && operator evaluates the false statement as false, it stops the evaluation, and will never evaluate the right side.

The following code generates CS0429.

// CS0429.cs
public class cs0429 
    public static void Main() 
        if (false && myTest())  // CS0429
        // Try the following line instead:
        // if (true && myTest())
            int i = 0;

    static bool myTest() { return true; }
© 2015 Microsoft