collections

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • =?Utf-8?B?cmF1bGF2aQ==?=

    collections

    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_Submit terEDIContactIn fos = 2;
    private void validate_Submit terEDIContactIn fos()
    {
    if (_SubmitterEDIC ontactInfos.Cou nt >
    MaxCount_Submit terEDIContactIn fos)
    Set Field Error ( "Too many rows ...bla,bla }
    private List<PER_EDICon tact_SubmitterE DIContactInfos;
    public List<PER_EDICon tactSubmitterED IContactInfos
    {
    get { return _SubmitterEDICo ntactInfos; }

    set
    {
    _SubmitterEDICo ntactInfos = value;
    validate_Submit terEDIContactIn fos();
    }
    }

    if i do 3 times
    SubmitterEDICon tactInfos.Add(n ew PER_EDIContact( file[c++]));
    SubmitterEDICon tactInfos.Add(n ew PER_EDIContact( file[c++]));
    SubmitterEDICon tactInfos.Add(n ew PER_EDIContact( file[c++]));

    the set property is not hit at all, why?


    set is only hit from constructor constructor

    public SubmitterName()
    {
    SubmitterEDICon tactInfos = new List<PER_EDICon tact>();
    }

  • =?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=

    #2
    RE: collections

    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<Tdoes not use the
    setter.
    -- Peter
    Site: http://www.eggheadcafe.com
    UnBlog: http://petesbloggerama.blogspot.com
    Short Urls & more: http://ittyurl.net


    "raulavi" wrote:
    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_Submit terEDIContactIn fos = 2;
    private void validate_Submit terEDIContactIn fos()
    {
    if (_SubmitterEDIC ontactInfos.Cou nt >
    MaxCount_Submit terEDIContactIn fos)
    Set Field Error ( "Too many rows ...bla,bla }
    private List<PER_EDICon tact_SubmitterE DIContactInfos;
    public List<PER_EDICon tactSubmitterED IContactInfos
    {
    get { return _SubmitterEDICo ntactInfos; }
    >
    set
    {
    _SubmitterEDICo ntactInfos = value;
    validate_Submit terEDIContactIn fos();
    }
    }
    >
    if i do 3 times
    SubmitterEDICon tactInfos.Add(n ew PER_EDIContact( file[c++]));
    SubmitterEDICon tactInfos.Add(n ew PER_EDIContact( file[c++]));
    SubmitterEDICon tactInfos.Add(n ew PER_EDIContact( file[c++]));
    >
    the set property is not hit at all, why?
    >
    >
    set is only hit from constructor constructor
    >
    public SubmitterName()
    {
    SubmitterEDICon tactInfos = new List<PER_EDICon tact>();
    }
    >

    Comment

    • =?Utf-8?B?cmF1bGF2aQ==?=

      #3
      RE: collections

      thanks Peter, I beleive so
      , How can I modify property to be checked ea time I add a row to collection ?
      SubmitterEDICon tactInfos.Add(n ew PER_EDIContact( file[c++]));
      is adding to a list not a collection , why?
      SubmitterEDICon tactInfos i though was the collection
      could you please, cexplain

      "Peter Bromberg [C# MVP]" wrote:
      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<Tdoes not use the
      setter.
      -- Peter
      Site: http://www.eggheadcafe.com
      UnBlog: http://petesbloggerama.blogspot.com
      Short Urls & more: http://ittyurl.net
      >
      >
      "raulavi" wrote:
      >
      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_Submit terEDIContactIn fos = 2;
      private void validate_Submit terEDIContactIn fos()
      {
      if (_SubmitterEDIC ontactInfos.Cou nt >
      MaxCount_Submit terEDIContactIn fos)
      Set Field Error ( "Too many rows ...bla,bla }
      private List<PER_EDICon tact_SubmitterE DIContactInfos;
      public List<PER_EDICon tactSubmitterED IContactInfos
      {
      get { return _SubmitterEDICo ntactInfos; }

      set
      {
      _SubmitterEDICo ntactInfos = value;
      validate_Submit terEDIContactIn fos();
      }
      }

      if i do 3 times
      SubmitterEDICon tactInfos.Add(n ew PER_EDIContact( file[c++]));
      SubmitterEDICon tactInfos.Add(n ew PER_EDIContact( file[c++]));
      SubmitterEDICon tactInfos.Add(n ew PER_EDIContact( file[c++]));

      the set property is not hit at all, why?


      set is only hit from constructor constructor

      public SubmitterName()
      {
      SubmitterEDICon tactInfos = new List<PER_EDICon tact>();
      }

      Comment

      • =?Utf-8?B?cmF1bGF2aQ==?=

        #4
        RE: collections

        Peter found an answer...

        o.SubmitterEDIC ontactInfos[1].variable02 = "thiswaschanged ";

        your response gave me a tip...

        I need to reference an item not the list as in
        SubmitterEDICon tactInfos.Add(n ew PER_EDIContact( file[c++]));



        "Peter Bromberg [C# MVP]" wrote:
        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<Tdoes not use the
        setter.
        -- Peter
        Site: http://www.eggheadcafe.com
        UnBlog: http://petesbloggerama.blogspot.com
        Short Urls & more: http://ittyurl.net
        >
        >
        "raulavi" wrote:
        >
        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_Submit terEDIContactIn fos = 2;
        private void validate_Submit terEDIContactIn fos()
        {
        if (_SubmitterEDIC ontactInfos.Cou nt >
        MaxCount_Submit terEDIContactIn fos)
        Set Field Error ( "Too many rows ...bla,bla }
        private List<PER_EDICon tact_SubmitterE DIContactInfos;
        public List<PER_EDICon tactSubmitterED IContactInfos
        {
        get { return _SubmitterEDICo ntactInfos; }

        set
        {
        _SubmitterEDICo ntactInfos = value;
        validate_Submit terEDIContactIn fos();
        }
        }

        if i do 3 times
        SubmitterEDICon tactInfos.Add(n ew PER_EDIContact( file[c++]));
        SubmitterEDICon tactInfos.Add(n ew PER_EDIContact( file[c++]));
        SubmitterEDICon tactInfos.Add(n ew PER_EDIContact( file[c++]));

        the set property is not hit at all, why?


        set is only hit from constructor constructor

        public SubmitterName()
        {
        SubmitterEDICon tactInfos = new List<PER_EDICon tact>();
        }

        Comment

        Working...