encapsulate array property in class

I want a  c# class which has two private int[] arrays or Lists I dont mind which but I want a public property which allows me to get and set. I don't know in advance how many ints I will be saving.

Can't seem to figure it out, is it possible? please show an example

Thanks
LVL 2
Paulmc999Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

AndyAinscowFreelance programmer / ConsultantCommented:
something like this should get you started
public class x
{
  private List<int> listIntOne = new List<int>();
  public void AddToOne(int i) {listIntOne.Add(i)};
  public int GetFromOne(long indx) {return listIntOne[indx]; };
}
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Bob LearnedCommented:
What is wrong with an automatic property?

public class IdContainer
{
    public List<int> IdList { get; private set; }

    public IdContainer()
    {
        IdList = new List<int>();
    }
}

Open in new window

0
Paulmc999Author Commented:
Guys I'm sorry I haven't responded, was very busy with something else. I did try these before but didn't know if it was right thing but perhaps I was doing something wrong. Am going to try it today and get back to you.

Thanks
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C#

From novice to tech pro — start learning today.