[Mono-devel-list] Comparing against null
michal.moskal at gmail.com
Sat Apr 9 05:00:52 EDT 2005
On Apr 9, 2005 1:07 AM, Jonathan Gilbert <2a5gjx302 at sneakemail.com> wrote:
> :-), simply because nobody has mentioned it yet, that there IS an official
> way to always do a reference check: ReferenceEquals(a, b). I do not know if
> the JIT recognizes when this compares against null and simplifies it to
> brtrue/brfalse, but it seems like an obvious -- and simple -- thing to do
> (just need to be careful that the user hasn't created their own 'new'
> static ReferenceEquals function).
Well, there is an easier way, which is clearly optimized:
(object)foo == (object)bar
More information about the Mono-devel-list