Is there a more elegant way of doing this? I really think this looks ugly.private static string InsertMethodNameHere( bool hasCondition1, bool hasCondition, bool hasCondition3)        {                if (!hasCondition1 && !hasCondition2 && !hasCondition3)                return 0;            if (hasCondition1 && !hasCondition2 && !hasCondition3)                return 1;            if (!hasCondition1 && hasCondition2 && !hasCondition3)                return 2;            if (hasCondition1 && hasCondition2 && !hasCondition3)                return 3;            if (!hasCondition1 && !hasCondition2 && hasCondition3)                return 4;            if (hasCondition1 && !hasCondition2 && hasCondition3)                return 5;            if (!hasCondition1 && hasCondition2 && hasCondition3)                return 6;            if (hasCondition1 && hasCondition2 && hasCondition3)                return 7;            throw new Exception(Unable to determine.);}
Multiple if then return with conditions
c#
How about this?private static string InsertMethodNameHere(bool hasCondition1, bool hasCondition2, bool hasCondition3){    return ((hasCondition1 ? 1 : 0) +            (hasCondition2 ? 2 : 0) +            (hasCondition3 ? 4 : 0)).ToString(CultureInfo.InvariantCulture);}If you want a more general solution, you could write an extension method that converts a list of bools to an int:public static int ToInt(this IEnumerable<bool> bools){    return bools.Select((t, i) => (t ? 1 : 0) << i).Sum();}