If you want to avoid ToLower () - the literal value "xx", you are stuck with the :: ternary operator.
xstring != null ? xstring.ToLower() : "xx"
Or you could write an extension method, but it looks very strange to me.
public static string ToLowerOrDefault(this string input, this string defaultValue) { return (input != null ? input.ToLower() : defaultValue); }
which you could use as follows:
xstring.ToLowerOrDefault("xx")
Michael gunter
source share