?
Solved

Question about Array.CreateInstance

Posted on 2014-09-18
2
Medium Priority
?
58 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 2000 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

Enroll in August's Course of the Month

August's CompTIA IT Fundamentals course includes 19 hours of basic computer principle modules and prepares you for the certification exam. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Suggested Courses

770 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