Solved

Question about Array.CreateInstance

Posted on 2014-09-18
2
56 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

Industry Leaders: 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

Suggested Solutions

Title # Comments Views Activity
Securing WEBAPI on Azure 2 55
Need to find a web event on the IIS server 4 52
Call to SQL server times out 5 53
How does this modal work? 3 33
We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

739 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