tags:

views:

84

answers:

4

I know it is a strange question did someone have had a case where a C# object return null after newing it up?

+4  A: 

Is this a trick question?

int? i = new int?();

if (i == null)
    Console.WriteLine("It's null!");
LukeH
BAHAHAA, LOL @ Luke
used2could
+4  A: 

Not possible by design, you'll always get an OutOfMemory exception if a new object cannot be created. A corrupted garbage collected heap is technically possible, invariably triggered by misbehaving unmanaged code, but I never heard of any cases where that didn't trigger an ExcecutionEngineException.

Hans Passant
A: 

I'm thinking he's got failing logic in the constructor of his object. There's no way this is happening to an object native to the asp.net framework.

used2could
A: 

Thanks for all people answered. No was not a trick question! But it ends up that the developer looked into the wrong sources and therefore this was misleading us. Sorry!!

mbr
I've done that a few times. There's nothing more frustrating than your debugger telling you that True == False.
Dan Bryant
I am afraid that's life and I was a not systematic enough. Sorry!
mbr