Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

newbee array question

Posted on 2006-10-23
4
Medium Priority
?
233 Views
Last Modified: 2010-04-16
Hi

what am i missing


 ArrayList parts = new ArrayList(parts);

 Gives me this error
 The type or namespace name 'ArrayList' could not be found (are you missing a using directive or an assembly reference?)      




  private void button1_Click(object sender, EventArgs e)
        {

            if (txtA.TextLength == 0)
                {
                    MessageBox.Show("manglende værdi for siden A");
                return ;
                }
            if (txtB.TextLength == 0)
                {
                    MessageBox.Show("manglende værdi for siden B");
                return ;
                }
            if (txtC.TextLength == 0)
                {
                    MessageBox.Show("manglende værdi for siden C");
                return ;
                }
                {
                ArrayList parts = new ArrayList(parts);
                parts.Add (txtA.Text);
                parts.Add (txtB.Text);
                parts.Add (txtC.Text);
                }
                 {                    
                     if (parts.Count == 3)
                         

                    switch (parts.size())  
                    {
                    case 1:
                         // it's equilateral
                         lblResult.Text=("equilateral");
                         break;
                    case 2:
                         // isoceles
                         lblResult.Text=("isoceles");
                         break;
                    case 3:
                         // scalene
                        lblResult.Text=("scalene");
                         break;
                    default:
                         lblResult.Text = ("Not a triangle");
                   }
               }
        }

vbturbo
0
Comment
Question by:vbturbo
  • 2
4 Comments
 
LVL 6

Assisted Solution

by:e1v
e1v earned 400 total points
ID: 17788064
add

using System.Collections;

to the top of your file
0
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 1600 total points
ID: 17788074
you need to either fully quantify the class:
 Sytem.Collections.ArrayList parts = new Sytem.Collections.ArrayList(parts);

or add the following in the top of the file in the "using" part:
using System.Collections;


note however that:
 ArrayList parts = new ArrayList(parts);  
must be wrong, as you are, according to that code, trying to initialize the variable with itself ????

this should work better:
 ArrayList parts = new ArrayList();


0
 
LVL 18

Author Comment

by:vbturbo
ID: 17788126
Yeah i see angelIII

but im totally new to C# so please carry over with me -;)

and im a vb.net fan but this is my homework to this evening at school

one last question


        private void button1_Click(object sender, EventArgs e)
        {

            if (txtA.TextLength == 0)
                {
                    MessageBox.Show("manglende værdi for siden A");
                return ;
                }
            if (txtB.TextLength == 0)
                {
                    MessageBox.Show("manglende værdi for siden B");
                return ;
                }
            if (txtC.TextLength == 0)
                {
                    MessageBox.Show("manglende værdi for siden C");
                return ;
                }
                {
                ArrayList parts = new ArrayList();
                parts.Add (txtA.Text);
                parts.Add (txtB.Text);
                parts.Add (txtC.Text);
                   
                     if (parts.Count == 3)                        

                    switch (parts.Count)  
                    {
                    case 1:
                         // it's equilateral
                         lblResult.Text=("equilateral");
                         break;
                    case 2:
                         // isoceles
                         lblResult.Text=("isoceles");
                         break;
                    case 3:
                         // scalene
                        lblResult.Text=("scalene");
                         break;
                    default:///////////////////////////////////////////// here i get: Error      Control cannot fall through from one case label ('default:') to another
                         lblResult.Text = ("Not a triangle");
                   }
               }
        }

thanks in advance
vbturbo
0
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 17788137
default:
                         lblResult.Text = ("Not a triangle");
    break;   /// add the following line
 
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

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

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.
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

916 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