Just realized IEnumerable is immutable, what are other commonly used immutable generic interfaces? MSDN doesn't say.
Or any good online resources?
Apart from the fact that it doesn't make a whole lot of sense to refer to interfaces as being immutable, IEnumerable<T>
isn't, for example:
List<string> myList = new List<string>();
myList.Add("Test"); // We just changed the state of myList, hence its not immutable
An example of an object that is immutable is String
.
It doesn't make sense for an interface to be immutable as almost by definition an immutable object needs to be sealed, which an interface obviously cannot be.
精彩评论