开发者

have you ever seen during runtime that an object (C#) returns null after constructing it? [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers. 开发者_如何学运维

This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.

Closed 8 years ago.

Improve this question

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


Is this a trick question?

int? i = new int?();

if (i == null)
    Console.WriteLine("It's null!");


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜