This repository has been archived on 2025-09-26. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
Password-Manager-Legacy/Password Manager/ProfileList.cs
2023-03-24 11:14:49 +01:00

63 lines
1.2 KiB
C#

using System;
namespace Password_Manager
{
sealed class ProfileList
{
private Profile[] list;
public int Length
{
get
{
return this.list.Length;
}
}
public Profile this[int index]
{
get
{
return this.list[index];
}
}
public ProfileList()
{
this.list = new Profile[0];
}
public void Add(Profile p)
{
//grow the list by 1 and copy all existing items
Profile[] tmp = new Profile[this.Length + 1];
for (int i = 0; i < this.Length; i++)
{
tmp[i] = this[i];
}
this.list = tmp;
//--------------------------------------------------------
list[this.Length - 1] = p;
}
public void Remove(Profile p)
{
Profile[] tmp = new Profile[this.Length - 1];
for (int i = 0; i < tmp.Length; i++)
{
if (this[i] != p)
{
tmp[i] = this[i];
}
}
this.list = tmp;
}
}
}