Solved

Question about Array.CreateInstance

Posted on 2014-09-18
2
57 Views
Last Modified: 2015-01-06
Below is an excerpt from a C#2012 book.
Question:
1. length specifies the size of the array to contain 6 elements, 2X3.  What is the lowerBoundsn for?
2.What is 0-baseed and 10-based referenced here?


The CreateInstance()method has many overloads to create multidimensional arrays and to create arrays
that are not 0-based. The following example creates a two-dimensional array with 2 X3 elements. The first
dimension is 1-based; the second dimension is 10-based:
int[] lengths = { 2, 3 };
int[] lowerBounds = { 1, 10 };
Array racers = Array.CreateInstance(typeof(Person), lengths, lowerBounds);

Thank you.
0
Comment
Question by:lapucca
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 75

Accepted Solution

by:
käµfm³d   👽 earned 500 total points
ID: 40331800
What is the lowerBoundsn for?
The starting index. Normally arrays are indexed from zero. When you change the lower bounds, you change at what index the array begins from.

What is 0-baseed and 10-based referenced here?
The author is just rephrasing that each array inside of racers starts at an index other than zero--the first starts at 1; the second from 10.

http://msdn.microsoft.com/en-us/library/x836773a(v=vs.110).aspx
0
 

Author Comment

by:lapucca
ID: 40360902
The length is 2x3 elements or 2 rows by 3 columns.  the pair of number for lower bound {1, 10}, indicates the racer array element can be access as below?
racer[1,10], racer[1,11], racer[1,12]
racer[2,10],racer[2,11], racer[2,12]

Thank you.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question