I’ve been trying to optimize my code to make it a little more concise and readable and was hoping I wasn’t causing poorer performance from doing it. I think my changes might have slowed down my application, but it might just be in my head. Is there any performance difference between:
Command.Parameters['@EMAIL'].Value = email ?? String.Empty;
and
Command.Parameters['@EMAIL'].Value = (email == null) ? String.Empty: email;
and
if (email == null) { Command.Parameters['@EMAIL'].Value = String.Empty } else { Command.Parameters['@EMAIL'].Value = email }
My preference for readability would be the null coalescing operator, I just didn’t want it to affect performance.
IMHO, optimize for readability and understanding – any run-time performance gains will likely be minimal compared to the time it takes you in the real-world when you come back to this code in a couple months and try to understand what the heck you were doing in the first place.