Item access operator . has a higher priority than the + operator.
Check C # Statements (MSDN) for C # statement priorities. In particular, it lists xy as "primary", which is higher than binary + in "additive".
This means that "xx" + "xx".StartsWith("x") interpreted as
"xx" + ("xx".StartsWith("x")) and does not compile. It combines string and a bool , which gives you string . But you cannot use string as a condition in an if , since it is not bool (and does not implement the true operator)
You seemed to expect it to be interpreted as ("xx" + "xx").StartsWith("x")) , where you first StartsWith lines and then call StartsWith on the concatenated line.
source share