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

middle

What is the use of Null Coalescing Operator ( ?? ) in C#?

senior

What is the Constructor Chaining in C#?

junior

What are generics in C#?

Bình luận

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

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