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 is scope of a Protected Internal member variable of a C# class?

senior

Can you create a function in C# which can accept varying number of arguments?

middle

What is scope of a Internal member variable of a C# class?

Bình luận

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

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