Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / March 2008

Tip: Looking for answers? Try searching our database.

collections

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
raulavi - 28 Mar 2008 20:36 GMT
vs2005 c#

how do i trap max number of row in a collection ?

lets say I can only have max of two rows in a collection

I have this property
       const int MaxCount_SubmitterEDIContactInfos = 2;
       private void validate_SubmitterEDIContactInfos()
       {
           if (_SubmitterEDIContactInfos.Count >
MaxCount_SubmitterEDIContactInfos)
               Set Field Error ( "Too many rows ...bla,bla          }
       private List<PER_EDIContact> _SubmitterEDIContactInfos;
       public List<PER_EDIContact> SubmitterEDIContactInfos
       {
           get { return _SubmitterEDIContactInfos; }

           set
           {
               _SubmitterEDIContactInfos = value;
               validate_SubmitterEDIContactInfos();
           }
       }

if i do 3 times
 SubmitterEDIContactInfos.Add(new PER_EDIContact(file[c++]));
SubmitterEDIContactInfos.Add(new PER_EDIContact(file[c++]));
SubmitterEDIContactInfos.Add(new PER_EDIContact(file[c++]));

the set property is not hit at all, why?

set is only hit from constructor constructor

       public SubmitterName()
       {
           SubmitterEDIContactInfos = new List<PER_EDIContact>();
       }
Peter Bromberg [C# MVP] - 28 Mar 2008 21:29 GMT
It looks to me like your set and get accesors are dealing with the list
itself, not an item in the list. The add method  of List<T> does not use the
setter.
-- Peter
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short Urls & more: http://ittyurl.net

> vs2005 c#
>
[quoted text clipped - 34 lines]
>             SubmitterEDIContactInfos = new List<PER_EDIContact>();
>         }
raulavi - 28 Mar 2008 21:39 GMT
thanks Peter, I beleive so
, How can I modify property  to be checked ea time I add a row to collection ?

> >   SubmitterEDIContactInfos.Add(new PER_EDIContact(file[c++]));
is adding to a list not a collection , why?
SubmitterEDIContactInfos i though was the collection
could you please, cexplain

> It looks to me like your set and get accesors are dealing with the list
> itself, not an item in the list. The add method  of List<T> does not use the
[quoted text clipped - 42 lines]
> >             SubmitterEDIContactInfos = new List<PER_EDIContact>();
> >         }
raulavi - 28 Mar 2008 22:32 GMT
Peter found an answer...

o.SubmitterEDIContactInfos[1].variable02 = "thiswaschanged";

your response gave me a tip...

I need to reference  an item not the list as in
       SubmitterEDIContactInfos.Add(new PER_EDIContact(file[c++]));

> It looks to me like your set and get accesors are dealing with the list
> itself, not an item in the list. The add method  of List<T> does not use the
[quoted text clipped - 42 lines]
> >             SubmitterEDIContactInfos = new List<PER_EDIContact>();
> >         }

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.