3
I was creating a model that in his construtor
i defined the attribute Nome
. however this attribute will only have the get
, as different from java
c# has the resource for getters and setters
I thought I’d just declare the get
, since Nome
would be set inside the classe
I believe there would be no restriction, but I was surprised when the VS
accused erro
. saying that the attribute Nome
is somente leitura
. but I’m setting him inside my própria classe
, Excuse my ignorance but why this restriction? It makes sense ? I believe that if this does not work I will have to work as in java attribute privado
and getter
public, right ?
public class Pessoa
{
public String Nome { get; }
public Pessoa(String nome) {
Nome = nome;
}
}
Thank you very much Rodrigo Santos.
– Tuyoshi Vinicius