views:

67

answers:

1

Possible Duplicate:
Is there a read-only generic dictionary available in .NET?

Hi everyone,

I realized that it was possible to return lists as read only collections:

var list = new List<string>();
return list.AsReadOnly();

I wanted to write a similar piece of code for data structures like Dictionary or HashSet but I didn’t find a way to achieve such a goal. Is there a way to return a Dictionary or a HashSet as a read-only collection?

Thank you.