1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Learning C #

Discussion in 'C#' started by JR042684, Sep 9, 2010.

  1. JR042684

    JR042684 New Member

    Sep 9, 2010
    Likes Received:
    Trophy Points:
    Hello all I am new to programming and have just started teaching myself C# for the past few weeks. I have come across a program that I have been trying to figure out. It is an address book program. It must store 20 entries. The information must be stored using arrays. The program must 1. display address book names only (alphabetical order last to first). 2. Display information about a contact letting the user do this 3. Add address entry 4. Delete address entry. The last name, first name will be stored in a listbox and once a user adds an entry the name will be added to the lsitbox. When a user selects a name from the list box it should display address information in the text boxes.

    So I have been trying to figure this out for myself but I am stuck. I have created a struct and than an array from that struct. I think I figured out how to add one entry to the array but i just can not figure out how to add the rest of the entries. Could someone point me in the right direction I am lost. Here is what I have coded so far:
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    namespace final_project_addressbook_cs
        public partial class final_project_addressbook_cs : Form
            public final_project_addressbook_cs()
            public struct AddressBook
                public string firstNameString;
                public string lastNameString;
                public string streetAddressString;
                public string stateString;
                public string cityString;
                public int zipCodeInteger;
            AddressBook[] Addresses = new AddressBook[20];
            private void addButton_Click(object sender, EventArgs e)
                   Addresses[0].firstNameString = firstNameTextBox.Text;
                   Addresses[0].lastNameString = lastNameTextBox.Text;
                   Addresses[0].streetAddressString = streetAddressTextBox.Text;
                   Addresses[0].stateString = stateTextBox.Text;
                   Addresses[0].cityString = cityTextBox.Text;
                   Addresses[0].zipCodeInteger = int.Parse(zipCodeTextBox.Text);
                   addressListBox.Items.Add(Address[0].lastNameString + ", " + firstNameString);
    This is really as far as I have gotten. I do not know if I even started doing this right. I have bought a C # book and am trying to teach myself how to program in it, so it is kind of difficult because the book does not do the best job explaining things. I think I am off to the right start but I can not seem to figure out how to get the rest of the array of 20 addresses from the text boxes that the user enters. Anyone please help me I have been tackling this for the past three days now....thanks!

Share This Page