NightOwl888 commented on pull request #345: URL: https://github.com/apache/lucenenet/pull/345#issuecomment-696844345
Interesting. I suspect they wouldn't produce the same IL if the type in the comparison had the `!=` operator overloaded - then it may produce very different results, and in fact depending on the implementation it might not produce expected results. `is` is safer because it doesn't take the operator overloads into account. That said, I am on board with elad in that using `== object` is not very intuitive for a `null` check. I prefer: ```c# public static void A(IMyInterface c) { if(!(c is null) && c is MyClass cc) { Console.WriteLine(cc.GetType()); } } ``` ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org