TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Steven Henley
NA
1
0
problem with derived collectionbase
May 2 2006 2:04 AM
Hello - As with most people, I am seeking assistance. I have few collection base collections that are adding to the collections within a while loop - have attempted this utilizing same code from within the collection class and from outside. In all cases, the collection is overwriting the previous collection items when an 'Add' is done. This is meant to break down a comma-delimited list of email address or group names from the To: (txt_To.Text) item on a form and return a collection of addresses and groups. Any assistance would be greatly appreciated. I have placed the new instantaition of Address within the while loop but continually, this overwrites previous entries. I have been stuck on this for over a day and really would appreciate some help. Steven Henley The code accessing the collection is as follows: private void btn_Send_Click(object sender, System.EventArgs e) { Address_List To_List = new Address_List(); if ( txt_To.Text.Length <= 0 ) { MessageBox.Show("This email has not been addressed to anyone", "Direct Mailer", MessageBoxButtons.OK, MessageBoxIcon.Exclamation ); txt_To.BackColor = Color.LightCoral; return; } To_List.generate_List( txt_To.Text ); txt_Body.Text = "Listing produced the following:"; for ( int counter = 0; counter < To_List.Count; counter++ ) { txt_Body.Text += "\n\t" + To_List[ counter ].address + "\t" + To_List[ counter ].type.ToString(); } } The collection class code is as follows: using System; using System.IO; using System.Collections; namespace Direct_Mailer.Classes { public class Address_List : CollectionBase { private static string _Name = null; public Address_List() { } public Address_List( string Name ) { _Name = Name; } #region Address List Methods #region Standard Methods public Address this[ int index ] { get { return ( Address )List[ index ]; } set { List[ index ] = value; } } public int Add( Address value ) { try { return List.Add( value ); } catch( Exception this_Exception ) { throw new Exception( "Add to the Address List failed.", this_Exception ); } } public void Insert( int index, Address value ) { try { List.Insert( index, value ); } catch( Exception this_Exception ) { throw new Exception( "Insertion into the Address List failed.", this_Exception ); } } public void Remove( Address value ) { try { List.Remove( value ); } catch( Exception this_Exception ) { throw new Exception( "Removal from the Address List failed.", this_Exception ); } } public int IndexOf( Address value ) { try { return List.IndexOf( value ); } catch( Exception this_Exception ) { throw new Exception( "Attempt of IndexOf failed in Address List.", this_Exception ); } } public void CopyTo( Address[] Address_Array, int index) { try { List.CopyTo( Address_Array, index ); } catch( Exception this_Exception ) { throw new Exception( "The CopyTo method failed in Address List.", this_Exception ); } } #endregion #region Class Specific Methods public string Name { get { return _Name; } set { _Name = value; } } static private Address this_Address = new Address(); public Address_List generate_List( string comma_delim ) { int begin_pos = 0, comma_pos = 0, amp_pos = 0; try { while( comma_pos >= 0 ) { comma_pos = comma_delim.IndexOf( ',', comma_pos ); if ( comma_pos <= 0 ) this_Address.address = comma_delim.Substring( begin_pos); else this_Address.address = comma_delim.Substring( begin_pos, comma_pos - begin_pos ); this_Address.address.Trim(); amp_pos = this_Address.address.IndexOf( '@' ); if ( amp_pos != -1 ) this_Address.type = Address.Type.Address; else this_Address.type = Address.Type.Group; List.Add( this_Address ); if ( comma_pos >= 0 ) begin_pos = amp_pos = ++comma_pos; } return this; } catch( Exception this_Exception ) { throw new Exception( "Error occured attempting to generate an Address List.", this_Exception ); } } #endregion #endregion } } The Class contained in the collection is: using System; using System.IO; namespace Direct_Mailer.Classes { public class Address { public Address() { } public enum Type { Address, Group }; private static string _address = null; public string address { get { return _address; } set { _address = value; } } private static Type _type = 0; public Type type { get { return _type; } set { _type = value; } } } } Thank you very much for any assistance that you can provide. Steven Henley
Reply
Answers (
0
)
XSLT Transformation
How to store and retrieve video in sql server with vb.net (urgent)