6

In the Apress book "Illustrated C# 2008", pg. 343 notes:

"One-dimensional arrays have specific instructions in the CIL that allow them to be optimized for performance. Rectangular arrays do not have these instructions...Because of this, it can sometimes be more efficient to use jagged arrays..."

Does anyone know how these performance optimizations are implemented?

Matthew Strawbridge
  • 19,940
  • 10
  • 72
  • 93
Scott Davies
  • 3,665
  • 6
  • 31
  • 39
  • Read [this article](http://www.codeproject.com/KB/dotnet/arrays.aspx). Note that it's written about version 1.0 of the CLR; I don't know how much has changed since. – SLaks Dec 31 '09 at 20:31
  • Thanks! One change appears to be that jagged arrays are now CLS compliant (see: http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=94823), while the CodeProject document states: "...jagged arrays are not CLS-compliant...". – Scott Davies Dec 31 '09 at 20:48
  • The CodeProject article links to this [MSDN article](http://msdn.microsoft.com/en-gb/magazine/cc163995.aspx). Although it's from 2004, it does include code for benchmarking jagged vs. rectangular arrays for both sequential and diagonal access. – Matthew Strawbridge Feb 29 '12 at 12:04

0 Answers0