0
I am making a very simple client registration application I would like to know how to program a method that calculates and returns the age (in years) from the attribute Anonascimento. I know how to do, for example, a "public Static int Calculaidade(Datetime x)", but to make a constructor method to calculate age from the year of birth really did not understand.
Below I put a screen print and the part of the code that is interesting to analyze:
    List<Pessoa> listcadastro = new List<Pessoa>();
    public class Pessoa
    {
        private string nome;
        private string endereço;
        private string ano_nascimento;
        private string telefone;
        public string Nome
        {
            get
            {
                return nome;
            }
            private set
            {
                nome = value;
            }
        }
        public string Endereço
        {
            get
            {
                return endereço;
            }
            private set
            {
                endereço = value;
            }
        }
        public string Ano_nascimento
        {
            get
            {
                return ano_nascimento;
            }
            private set
            {
                ano_nascimento = value;
            }
        }
        public string Telefone
        {
            get
            {
                return telefone;
            }
            private set
            {
                telefone = value;
            }
        }
        public Pessoa(string nome, string endereço, string ano_nascimento, string telefone)
        {
            this.nome = nome;
            this.endereço = endereço;
            this.ano_nascimento = ano_nascimento;
            this.telefone = telefone;
        }
    }
private void bt_salvar_Click(object sender, EventArgs e)
{
    listcadastro.Add(new Pessoa(txt_ano.Text, txt_nome.Text, txt_endereco.Text, txt_telefone.Text));
    dataGridView1.DataSource = null;
    dataGridView1.DataSource = listcadastro;
}
private void novoMenuItem_Click_1(object sender, EventArgs e)
{
    txt_nome.Enabled = true;
    txt_ano.Enabled = true;
    txt_endereco.Enabled = true;
    txt_telefone.Enabled = true;
    if (bt_pjuridica.Checked)
    {
        txt_registro.Enabled = true;
        txt_registro.Mask = "00,000,000/0000-00";
    }
    if (bt_pfisica.Checked)
    {
        txt_registro.Enabled = true;
        txt_registro.Mask = "000,000,000-00";
    }
}

Thank you very much!
– user67662