KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I have a class named WhatClass that has List field in it. I need to be able to read-only this field, so I used a get property to expose it to other objects. public class WhatClass { List<SomeOtherClass> _SomeOtherClassItems; public List<SomeOtherClass> SomeOtherClassItems { get { return _SomeOtherClassItems; } } } However it turns out that any object can call WhatClass.SomeOtherClassItems.Add(item); How can I prevent this?
Tags (comma-separated)
Save Edits
Cancel