C#

public class KPage public KPage() this.Titolo = "example"; public string Titolo get return Titolo; phối Titolo = value; I phối data by the constructor. So, I"d like khổng lồ vị somethings like

KPage page = new KPage();Response.Write(page.Titolo);but I get that error on :

phối Titolo = value;

Bạn đang xem: C#

*

*

You have sầu an infinite loop here:

public string Titolo get return Titolo; set Titolo = value; The moment you refer lớn Titolo in your code, the getter or setter gọi the getter which calls the getter which calls the getter which calls the getter which calls the getter... Bam - wpcyte.comException.

Either use a backing field or use auto implemented properties:

public string Titolo get; set;Or:

private string titolo;public string Titolo get return titolo; set titolo = value;

*

You have sầu a self-referential setter. You probably meant to lớn use auto-properties:

public string Titolo get; set;

*

Xem thêm: Cách Xuống Dòng Trong Google Sheet S Dễ Đơn Giản Nhất, Cách Các Xuống Dòng Trong Google Sheets

Change to

public class KPage public KPage() this.Titolo = "example"; public string Titolo get; set;

*

Thanks for contributing an answer lớn Stachồng Overflow!

Please be sure to answer the question. Provide details and tóm tắt your research!

But avoid

Asking for help, clarification, or responding lớn other answers.Making statements based on opinion; baông chồng them up with references or personal experience.

To learn more, see our tips on writing great answers.


Post Your Answer Discard

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy


Not the answer you're looking for? Browse other questions tagged c# .net stack-overflow getter-setter or ask your own question.


How vì chưng I get a consistent byte representation of strings in C# without manually specifying an encoding?
site thiết kế / biểu tượng logo © 2022 Stachồng Exchange Inc; user contributions licensed under cc by-sa. rev2022.1.7.41110


Your privacy

By clicking “Accept all cookies”, you agree Staông xã Exchange can store cookies on your device & discđại bại information in accordance with our Cookie Policy.