Junior From PDF OOP C# OOP

What is the use of properties in encapsulation?

  • Properties provide controlled access to private fields.
  • Enable validation, read-only/write-only access, and future flexibility.

Example:

private int score;
public int Score
{

get { return score; }

set { if (value >= 0) score = value; } // validation
}

More from C# Programming Tutorial

All questions for this course
Toolliyo Assistant
Ask about tutorials, ebooks, training, pricing, mentor services, and support. I use public site content only—not admin or internal tools.

care@toolliyo.com

Need callback? Share your details