I saw this operator in use today in a code example. I must say when I figured what it does my geek side went "YES!!!!".
It resembles an old "if" abbreviation:
(condition ? true result : false result);
now what ?? does is a null check same as the SQL Servers Coalesce function. It returns the first non null parameter.
function test(class1 variable)
if (variable == null)
variable = new class1();
// equals to
variable = (variable ?? new class1());
I'm starting to use this and giving a "What!?!???" moment...
why is there no reverse string function in c#?? Is there realy no need for that function??
there are of course a few ways to make your own reverse function. most favorite is definitly the one using recursion with substring. that's preety cool i thought why not... and then i remembered something that i learned in my first year of college... bitwise operations. i knew that there was a handy little way of switching 2 values using something with XOR without using a 3rd variable. i just couldn't remember it... so i went googling... it sure was faster than going through...