We help IT Professionals succeed at work.

# Review my answers on arrays

on
194 Views

//1. Create an array of integers named MyIntegerArray, and make it so that it will hold ten elements.  Do this on one line of code.  1.2

int [] MyIntegerArray = new int [10];

//2. Create an array of strings with the name MyStringArray, and give it a holding capacity of seventeen strings.  Do this with two lines of code.  1.2

String [] MyStringArray;
MyStringArray = new String[17];

//3. Create an implicitly sized string array called Beatles, with the elements John, Paul, George, and Ringo.  1.2

String [] Beatles = {"John"," Paul", "George", "Ringo"};

//4. Use Sort on your Beatles array to put the names in alphabetical order.  1.3

Array.Sort(Beatles);

//5. Call the IsSynchronized property for any of the arrays you created and check to see if they are threadsafe.  1.3

if (MyIntegerArray.IsSynchronized)
if (MyStringArray.IsSynchronized)
if (Beatles.IsSynchronized)

//6. Write the code for a loop that will go through an array and load elements into it.  1.3

for (int i = 0; i < MyIntegerArray.Length; i++)
MyIntegerArray[i] = i;

//7. Create a four dimensional rectangular array of integers.  1.4

int [,,,] FourDimensionalArray = new int[3,3,3,3];

//8. Create a two dimensional, ragged array of integers.  1.4

int [][] TwoDimensionalArray = new int[3][];
Comment
Watch Question
Senior Systems and Integration Developer
CERTIFIED EXPERT
Commented:
This problem has been solved!
Unlock 1 Answer and 1 Comment.
###### Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

Deciding to stick with EE.

Mohamed Asif

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant