Accepted answer

the thing that sticks out to me with what you have in the code is the


part. this does a string comparison with case sensitivity. your value for the dictionary item converts the boolean to a string with either the value "false" or "true". the simplest solution would be to change your linq where statement to:


but this may not be the best solution, as this looks for "true" in any part of the string, and is still case sensitive. a "better" solution would be to use a comparison method that allows for case insensitivity. an extension method i have used a few times in projects is this:

public static bool contains(this string source, string tocheck, stringcomparison comp)
    if (string.isnullorempty(tocheck) || string.isnullorempty(source))
        return false;
     return source.indexof(tocheck, comp) >= 0;

and you could change the where statement to:

x.key.contains("true", stringcomparison.invariantcultureignorecase)

if you are not using .net 3.0 or greater, you can easily just change that to a static utility method.

Related Query

More Query from same tag