Solved

Review my answers on arrays

Posted on 2006-06-15
1
175 Views
Last Modified: 2010-04-16

//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][];
0
Comment
Question by:noam_dz
1 Comment
 
LVL 52

Accepted Solution

by:
Carl Tawn earned 100 total points
ID: 16918832
They all look correct to me.

As with all things the best way to check is to build them into a test app and make sure they all function as expected.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
detecting  the added row index in a datagridview 3 54
Get String split 5 46
Run time Error 4 34
C#  Radio button search for Date not DateTime 4 30
Extention Methods in C# 3.0 by Ivo Stoykov C# 3.0 offers extension methods. They allow extending existing classes without changing the class's source code or relying on inheritance. These are static methods invoked as instance method. This…
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.
This is a video that shows how the OnPage alerts system integrates into ConnectWise, how a trigger is set, how a page is sent via the trigger, and how the SENT, DELIVERED, READ & REPLIED receipts get entered into the internal tab of the ConnectWise …
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

932 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now