create readonly collection
Published: 14. February 2012 | Updated: 14. February 2012License: Microsoft Public License (MS-PL)
Categories: Collections
Tags: C# Collections Linq
Import namespaces
using System; using System.Collections.Generic; using System.Collections.ObjectModel;
Code
var items = new List<MyClass>(); // ... fill collection ReadOnlyCollection<MyClass> collection = items.AsReadOnly(); // or ReadOnlyCollection<MyClass> collection = new ReadOnlyCollection<MyClass>(items);
| Send us feedback about this snippet » |





