I want to create a new user and save it in my list. Im new in C#, and I don´t know how I´m going to solve this. I´m using list.
using MetroFramework.Forms;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace SGE
{
public partial class Registar_Utilizador : MetroForm
{
string username, password, tipo;
List<Pessoa> todos = new List<Pessoa>();
List<Pessoa> novaListaPessoa = new List<Pessoa>();
public Registar_Utilizador(List<Pessoa> todos)
{
InitializeComponent();
}
private void metroButtonAdicionar_Click(object sender, EventArgs e)
{
int i = 0;
Pessoa p = new Pessoa();
do
{
p.setusername(metroTextBoxUsername.Text);
}while(i < todos.Count && p.getusername() == todos[i++].getusername());
}
}
}
[Error] Error 1 Use of unassigned local variable 'todos'