Solved

newbee array question

Posted on 2006-10-23
4
224 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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Article by: Ivo
C# And Nullable Types Since 2.0 C# has Nullable(T) Generic Structure. The idea behind is to allow value type objects to have null values just like reference types have. This concerns scenarios where not all data sources have values (like a databa…
Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

706 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

16 Experts available now in Live!

Get 1:1 Help Now