Resharper is telling me to change the way I was doing some conditional statements.
THe line of code is within an XMLTextReader.Read() method where I go:
c = xReader["MyAttribute"] == null ? string.Empty : xReader["MyAttribute"].ToString();
It wanted me to go to:
c = xReader["MyAttribute"] ?? String.Empty;
The questions I have, is what does .NET Check against with the ?? opperator? It seems to me that telling the compiler to check to see if it's null, is more efficient because you're giving it specific instructions. The way resharper asks me to do it leaves it up to the compiler to make the decisions.
Also, it's also inneficient to send an object to a string variable, as xReader[""] returns an object and not a string.
Would it not make more sense to return xReader["MyAttribute"].ToString() vs xReader["MyAttribute"] ?
I don't mind coding 10x the amount of code, as long as everything is efficient and executes quickly (I don't care how convoluted my code looks either :P)