Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

newbee array question

Posted on 2006-10-23
4
Medium Priority
?
232 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 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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

721 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