I was creating a template that in its construtor
I set the Nome
attribute. however, this attribute will only have get
, as opposed to java
oc # has the resource for getters and setters
I thought I would simply declare get
, since since Nome
would be set inside classe
I believe that there would be no restriction, but I was surprised when VS
accused erro
. saying that the Nome
attribute is somente leitura
. but I'm setting it inside my própria classe
, excuse my ignorance but why this restriction? that makes sense ? I believe that if this does not work I will have to work as in java atributto privado
and getter
public, right?
public class Pessoa
{
public String Nome { get; }
public Pessoa(String nome) {
Nome = nome;
}
}