Hi,

I'm working on a Generic Dictionary in C# and have came across a little problem with my add function.
My add function at the moment will take two inputs: Name and Age and then add them to the listBox associated with them.
What I'm trying to do is make the function accept another 3 entries, Height, Offences and Address but I've had no luck.

Currently I have this for my function:

 void AddBook(int isbn, string title, int Height)
        {
            criminals.Add(title, new Criminal(isbn, title));
        }

        private void Addbtn_Click(object sender, EventArgs e)
        {
            if (NameBox.Text != "" && AgeBox.Text != "" && HeightBox.Text != "")
            {
                if (AgeBox.Text.Length <= 3)
                {
                    ***if (HeightBox.Text.Length <= 5)
                    {
                        AddBook(int.Parse(AgeBox.Text), NameBox.Text, HeightBox.Text);***
                    }
                    else
                    {
                        MessageBox.Show("Age must be max 3 numbers in length");
                    }
                }
                else
                {
                    MessageBox.Show("Name Title and Age fields must be filled");
                }
                UpdateListBox();
            }
        }

The part in bold italic is where I have had a go at extending it myself.
I also have another class which ties in with this function:
Criminal.cs:

class Criminal
    {
        private int isbn;
        private string title;

        public Criminal(int isbn, string title)
        {
            this.isbn = isbn;
            this.title = title;
        }

        public int ISBN
        {
            get { return isbn; }
        }

        public string Title
        {
            get { return title; }
        }
    }
}

So, How can I achieve extending this function to take upto 5 inputs?

EDIT: On another note the isbn and title are used as I copied the coding from another program that acts as a library.
Also, The program is for Criminal Records.

I've solved it nevermind :P

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.