I'm working on a school project and everything was going alright before I though about the patients management. I've to create a program in a form that is able to manage patients and store them in memory, I thought about using a struct but then I changed to class.
I've to save the patient id, name, age, address, e-mail and store the medical interventions (might be many so I thought about using another array for that) he had so I made the class Patient like this:
public class Paciente
{
public int id;
public string nome;
public int idade;
public string morada;
public string contato;
public string email;
public Array intervencoes;
}
And by introducing a new patient I would use List with add like this:
private void bAdicionar_Click(object sender, EventArgs e)
{
List<Paciente> pacientes = new List<Paciente>();
pacientes.Add(new Paciente { id = Convert.ToInt32(txtID.Text), nome = txtNome.Text, idade = Convert.ToInt32(txtIdade.Text), morada = txtMorada.Text, contato = txtNumero.Text, email = txtEmail.Text });
}
Is this correct? And how can I use foreach search the array for the id that the user introduced to get all the remaining information? If I'm wrong, how should I be doing it since I want to store all that data in memory.