Non-Modifiable Lists in C #

In Java, you can use the Collections # unmodifiableList () method to create an unmodifiable list from an existing List object. Is there any copy in C #? I am new to the language and could not find anything like it in MSDN docs.

+4
source share
1 answer

ReadOnlyCollection

var dinosaurs = new List<string>(); dinosaurs.Add("Tyrannosaurus"); dinosaurs.Add("Amargasaurus"); dinosaurs.Add("Deinonychus"); dinosaurs.Add("Compsognathus"); var readOnlyDinosaurs = new ReadOnlyCollection<string>(dinosaurs); 
+16
source

All Articles