Solved

newbee array question

Posted on 2006-10-23
4
230 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 143

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 143

Expert Comment

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

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
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!
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …

623 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