I know it is a strange question did someone have had a case where a C# object return null after newing it up?
views:
84answers:
4
+4
A:
Is this a trick question?
int? i = new int?();
if (i == null)
Console.WriteLine("It's null!");
LukeH
2010-03-15 14:39:26
BAHAHAA, LOL @ Luke
used2could
2010-03-15 14:43:57
+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
2010-03-15 14:40:08
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
2010-03-15 14:42:24
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
2010-03-15 14:45:55
I've done that a few times. There's nothing more frustrating than your debugger telling you that True == False.
Dan Bryant
2010-03-15 14:48:06