static void Foo2() { var rep = PersonalRepository.Getinstance(); foreach (var item in rep.GetAll()) { Console.WriteLine($"{item.Name} {item.Age} {item.Surname}"); } }
public static PersonalRepository Getinstance() { if (_instance == null) { _instance = new PersonalRepository(); } return(_instance); }
static void Foo1() { var rep = PersonalRepository.Getinstance(); rep.Add(new Person { Name = "Name", Age = 18, Surname = "Surname" }); rep.Add(new Person { Name = "Name2", Age = 20, Surname = "Surname2" }); }