Take the 2-minute tour ×

Hi for some reason the break at the end of the "AndGroup" case is unreachable. I have tried to fix this with a goto and even moving the "return true" without result. Can anyone help me out?

switch (dependant[0])
        case "AndGroup": 
             string[] sAndItems = 

            foreach (string sAndItem in sAndItems)
                if (SC_Product.Dependancies.ContainsKey(sAndItem))
                    if (!SC_Product.Dependancies[sAndItem].DependantInstalled)
                        return false;
            return true;

        case "Windows":
share|improve this question
can we have the whole block of code, is it a method or what ? –  dotNetSoldier Feb 20 '12 at 21:33
add comment

2 Answers

up vote 2 down vote accepted

The break is unreachable because you have already exited via return true - there's no possible code branch by which the break can be executed.

share|improve this answer
add comment

Stuart is right "there's no possible code branch by which the break can be executed" , you may set a field but don't use return.

share|improve this answer
I forgot to add a break; statement to the windows case. Adding the break; and returning the bool value by means of a variable seemed to fix the problem! Thank you for your input. –  p0enkie Feb 21 '12 at 5:39
add comment

Your Answer


