Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

i have a customer object and a phone object. the phone object is a property of the customer object in the form of an array.

 

i'm not sure how to explain this, but look at this code:

// if the phone array contained 2 elements
// this is how i could access the phone numbers
MessageBox.Show(Customer.Phone[0].Text);
MessageBox.Show(Customer.Phone[1].Text);

// add a phone to the array with this call
Customer.Phone.Add("8005551212");

 

how do i create that "Add" method to Phone without having to reference a specific instance of that phone array?

 

i mean:

 

Phone.Add vs. Phone[0].Add

 

does this make sense?

Posted

if you want to do it in that way then you have to add a parameter for the index like

 

public void Add(string PhoneNumber, int index)
{
   Customer.Phone[index].Text = PhoneNumber; 
}

Posted

thanks, but i'm still a little confused.

 

is there any way to put this Add method in the Phone class though? with your example, you reference the customer object.

 

hmm .. would i pass the customer object in by reference then too?

  • *Experts*
Posted

You wouldn't add the Add method to the Phone class, since

it already has one. Instead, you would inherit some type of

collection and overload the Add method, like PlausiblyDamp

mentioned.

"Being grown up isn't half as fun as growing up

These are the best days of our lives"

-The Ataris, In This Diary

Posted

well i'm coding this in avr.net for as/400 access, but you get the idea:

	dclfld CustomerID 	type(*string) access(*public)
dclfld AreaCode		type(*string) access(*public)
dclfld Prefix		type(*string) access(*public)
dclfld Suffix		type(*string) access(*public)
dclfld Extention	type(*string) access(*public)
dclfld PhoneType	type(*string) access(*public) // HMVC,HMFX,BSVC,BSFX,CELL,UNKN

 

i like the ArrayList idea. could i override the Add method of that array list ? the add method i want to impliment will add it to the database when it adds the number to the collection.

 

at this point, i think it is best if i make a method in the customer class to add a phone number, and then just refresh the data. it just seemed logical to attempt it the other way.

 

thanks for the help!

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...