Why this? This is my code :
public class KPage
{
public KPage()
{
this.Titolo = "example";
}
public string Titolo
{
get { return Titolo; }
set { Titolo = value; }
}
}
I set data by the constructor. So, I’d like to do somethings like
KPage page = new KPage();
Response.Write(page.Titolo);
but I get that error on :
set { Titolo = value; }
You have an infinite loop here:
The moment you refer to
Titoloin your code, the getter or setter call the getter which calls the getter which calls the getter which calls the getter which calls the getter… Bam –StackOverflowException.Either use a backing field or use auto implemented properties:
Or: