Câu hỏi phỏng vấn C#
Câu hỏi

IEnumerable vs List - What...

Câu trả lời

Here is a concise answer to your C# interview question comparing IEnumerable and List:

IEnumerable and List are both used to work with collections of elements in C#, but they have some key differences:

  • IEnumerable is an interface that provides a way to access a sequence of elements. It is a read-only collection and does not provide methods to add, remove or modify elements. It is useful when you only need to iterate over the collection and don't need to modify it[1].

  • List is a concrete class that implements IEnumerable and provides additional methods to add, remove, insert and access elements by index. It is a mutable collection that allows you to dynamically change its size[1].

In terms of when to use each:

  • Use IEnumerable when you only need to iterate over the collection and don't need to modify it. This i...
senior

senior

Gợi ý câu hỏi phỏng vấn

senior

What interface should your data structure implement to make the Where method work?

middle

What is the difference between Equality Operator ( == ) and Equals() Method in C#?

junior

Can multiple catch blocks be executed?

Bình luận

Chưa có bình luận nào

Chưa có bình luận nào