Solved

Review my answers on arrays

Posted on 2006-06-15
1
174 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
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!
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

708 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

14 Experts available now in Live!

Get 1:1 Help Now