KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
When I want to make a value type read-only outside of my class I do this: public class myClassInt { private int m_i; public int i { get { return m_i; } } public myClassInt(int i) { m_i = i; } } What can I do to make a List<T> type readonly (so they can't add/remove elements to/from it) outside of my class? Now I just declare it public: public class myClassList { public List<int> li; public myClassList() { li = new List<int>(); li.Add(1); li.Add(2); li.Add(3); } }
Tags (comma-separated)
Save Edits
Cancel