[Mono-list] new operator in C#

Raja R Harinath rharinath@novell.com
Wed, 06 Apr 2005 14:56:19 +0530


Hi,

Kala B <kalabalun@gmail.com> writes:

> If the C# new operator fails to allocate memory, does it return null?
> ( and throw the OutOfMemoryException). What is the expected/defined
> behaviour ?

According to Section 14.5.10.1 of the standard, it throws an
OutOfMemoryException.  You can find it online in the MSDN C# Language
Specification (it's section 7.5.10.1 there though).

  http://msdn.microsoft.com/library/en-us/csspec/html/vclrfcharpspec_7_5_10_1.asp

> Is a null check enough ? 

A null check is not necessary.

- Hari