From looking at the intermediate language for a similar example there is
very little difference between the two. Any difference between the two is
negligible in terms of performance.
I've included the IL from my test as an example so you can see what's going
on behind the scenes. You can see that the first type (if...else) branches
if the condition is false loads the string (True!), assigns it, then
branches out of the statement or (if the condition was false) loads the
string (False!), assigns it, and continues execution. The second type
(ternary operator) branches if the condition is true, loads the false string
then branches to the assignment otherwise if the condition was true it loads
the true string and assigns it. Long story short, we're talking about one
line IL more in the if...else version.
..method public hidebysig static void Main() cil managed
{
.entrypoint
// Code size 48 (0x30)
.maxstack 2
.locals init (bool V_0,
string V_1,
string V_2)
IL_0000: ldc.i4.1
IL_0001: stloc.0
IL_0002: ldloc.0
IL_0003: brfalse.s IL_000d
IL_0005: ldstr "True!"
IL_000a: stloc.1
IL_000b: br.s IL_0013
IL_000d: ldstr "False!"
IL_0012: stloc.1
IL_0013: ldloc.1
IL_0014: call void [mscorlib]System.Console::WriteLine(string)
IL_0019: ldloc.0
IL_001a: brtrue.s IL_0023
IL_001c: ldstr "False!"
IL_0021: br.s IL_0028
IL_0023: ldstr "True!"
IL_0028: stloc.2
IL_0029: ldloc.2
IL_002a: call void [mscorlib]System.Console::WriteLine(string)
IL_002f: ret
} // end of method TestApplication::Main