Just curious as to how I can get this error the easiest way.
Once I was trying to create a file navigator and I was creating Image thumbnails; that turned out awful.
void Foo()
{
throw new OutOfMemoryException();
}
:)))
Create a very, very large string. Probably:
string s = new string('a', int.MaxValue);
will be enough.
If not, you can concat it to build even bigger string.
string ss = string.Concat(s, s);
This does throw an OutOfMemoryException
:
string s = " ";
while (true) s += s;
for(var s=" ";;s+=s);
var x = new long[Int32.MaxValue];
应该这样做。
你可以用这个:
new int[(ulong)-1];
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.