Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Text;
- namespace Repository
- {
- public class Repository
- {
- private List<Person> collection;
- public Repository()
- {
- collection = new List<Person>();
- }
- public int Count => collection.Count;
- public void Add(Person person)
- {
- collection.Add(person);
- }
- public Person Get(int id)
- {
- return collection[id];
- }
- public void Update(int id, Person newPerson)
- {
- Person person = newPerson;
- collection[id] = person;
- }
- public bool Delete(int id)
- {
- if (collection.Contains(collection[id]))
- {
- collection.Remove(collection[id]);
- return true;
- }
- else
- {
- return false;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement