Check out this code:
static void Main(string[] args) { string test = null; Console.WriteLine("Is test null: " + test == null); Console.ReadLine(); }
And guess the output without running the code.
About .NET/C#, Xamarin, Flutter and other fun technologies
Check out this code:
static void Main(string[] args) { string test = null; Console.WriteLine("Is test null: " + test == null); Console.ReadLine(); }
And guess the output without running the code.
You must be logged in to post a comment.
Can you explain that outcome. I guess wrongly true. Interested in hearing your feedback.
i guess “false”
because the first step is to concat “is test null:” + test –> “is test null:
and after the concatination the string will be compared to null –> false
Hi Josh,
Giuseppe is correct. The order of operators is misleading in this case. As a human you know what you want to achieve and it seems logical that it will work, but the operator precedence is not what you would think. 🙂 + has a precedence over ==.
One can find the operator precedence order here:
http://msdn2.microsoft.com/en-us/library/6a71f45d(VS.80).aspx
i have a good riddle as well (T-SQL):
SELECT DATEADD(MONTH, 1 , ‘20070131’)