To reuse an array from an ArrayPool, we "rent" it with the Rent() method. We can then Return() the same array to allow later uses.
An example. Here we introduce a method called UseSharedArray that uses the ArrayPool generic type. We call UseSharedArray 3 times with a different number.
A summary. For complex array sharing requirements, ArrayPool is a good choice. For simple programs where only one array is shared, a static array can be used.
Dot Net Perls is a collection of tested code examples. Pages are continually updated to stay current, with code correctness a top priority.
Sam Allen is passionate about computer languages. In the past, his work has been recommended by Apple and Microsoft and he has studied computers at a selective university in the United States.
This page was last updated on Dec 7, 2022 (simplify).