Solved

newbee array question

Posted on 2006-10-23
4
225 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 100 total points
ID: 17788064
add

using System.Collections;

to the top of your file
0
 
LVL 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 400 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 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 17788137
default:
                         lblResult.Text = ("Not a triangle");
    break;   /// add the following line
 
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
bulid json format 3 46
Visual Studio 2013 debugging 2 35
coded character set iptc field within a jpeg 1 68
C#.NET and microsoft certification. 3 30
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…
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…
This is a video describing the growing solar energy use in Utah. This is a topic that greatly interests me and so I decided to produce a video about it.
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 …

911 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

19 Experts available now in Live!

Get 1:1 Help Now