Is there a specific collection type in .NET that allows storing a limited number objects and removing the oldest element automatically? What’s the easiest way to implement such “Recent Files” functionality?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You might want to try System.Collections.Queue?
Each time before you add an object to your Queue (
Enqueue()), you can check theCountto decide if you need the oldest object to be removed (Dequeue()).