First thing is that the two strings are not access modifiers , they are private and will only be accessible within the class itself.
Taking advantage of and changing the code, because it makes no sense to call a class called nome
and two students inside it. The code should look like this:
public class Aluno
{
public string Nome {get;set;}
}
Now in form
, you could instantiate your students. Example:
Aluno alunoA = new Aluno(){ Nome = "Aluno Exemplo A" };
Aluno alunoB = new Aluno(){ Nome = "Aluno Exemplo B" };
Finally, you could display the message:
MessageBox.Show(alunoA.nome,"Aluno");
This last bit has to be inside some method or event of form
, a click of a button for example:
private void button1_Click(object sender, EventArgs e)
{
Aluno alunoA = new Aluno(){ Nome = "Aluno Exemplo A" };
Aluno alunoB = new Aluno(){ Nome = "Aluno Exemplo B" };
MessageBox.Show(alunoA.Nome+"\n"+ alunoB.Nome,"Alunos");
}