What is private set in C#?

private setters are same as read-only fields . They can only be set in constructor. If you try to set from outside you get compile time error. public class MyClass { public MyClass() { // Set the private property. this.Name = “Sample Name from Inside”; } public MyClass(string name) { // Set the private property.

Sizin İçin Seçtik  Is constructor necessary in C#?

Leave a Reply

Your email address will not be published. Required fields are marked *