Link to home
Start Free TrialLog in
Avatar of John Bolter
John Bolter

asked on

Create a List<sometype> of a certain size

Hi, I am writing to ask if anyone knows of an existing .Net framework 4.5 class that allows a list of a certain size, and when the size is exceeded, it just drops off/loses one off the end keeping the most recent items.

For example

  SomeListClass<int> slc = new SomeListClass<int>(3);  //can contain only 3 items
  slc.Add(1);     //list contains 1
  slc.Add(2);     //list contains 1,2
  slc.Add(3);     //list contains 1, 2, 3
  slc.Add(4);     //list contains 2, 3, 4
  slc.Add(100);//list contains 3, 4, 100

Open in new window


I could easily roll my own, but I don't want to do this if it is already provided by .Net
ASKER CERTIFIED SOLUTION
Avatar of Jacques Bourgeois (James Burger)
Jacques Bourgeois (James Burger)
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of kaufmed
I'm 99% sure that you'll have to roll your own.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of John Bolter
John Bolter

ASKER

Thanks everyone. This has all been so helpful.
I have a lot to learn !!