Wednesday 20 November 2019

c# - Difference between IEnumeration instead and List?

You mean IEnumerable. It's the base interface of all collection types like arrays or generic List.



You can for example create a List:



List ints = new List(){ 1,2,3 };


But since it implements IEnumerable you could also declare it in this way:




IEnumerable ints = new List(){ 1,2,3 };


This has the advantage that you cannot modify ints since Remove comes from ICollection.

No comments:

Post a Comment

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...