Like virtually all modern languages, C# has a built-in Boolean data type. This means that the only values eligible for variables of that data type are true and false, and unfortunately not FILE_NOT_FOUND. In addition, all data types in C# have a ToString() method, which does just that; for Booleans, it returns the appropriate of the two constants System.Boolean.TrueString or System.Boolean.FalseString.

So given that (which, you probably already knew anyway), how would you convert a Boolean to its string representation? If, like Malcolm colleague, you answered the following, give yourself a point!

// "true" or "false"
public static string Bool2Str(bool b)
{
    switch(b)
    {
        case true:
            return System.Boolean.TrueString;
        case false:
            return System.Boolean.FalseString;
        default:
            return "error";
    }
}

Malcolm adds, "Luckily, this 'helper function' was never called, and I was more than happy to delete it. Apparently, the guy who wrote this didn't stay on the job long enough to actually use it."

[Advertisement] BuildMaster allows you to create a self-service release management platform that allows different teams to manage their applications. Explore how!