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

What interface should your data structure...

Câu trả lời

To make the Where method work in C#, your data structure should implement the IEnumerable<T> interface. The IEnumerable<T> interface is part of the .NET Standard and is used to represent a collection of objects that can be iterated over.

By implementing the IEnumerable<T> interface, your data structure will provide a way to access its elements using a foreach loop or LINQ methods like Where, Select, OrderBy, and more.

Here's an example of how you can implement the IEnumerable<T> interface in your data structure:

csharp Copy
public class MyDataStructure<T> : IEnumerable<T>
{
    private T[] _items;

    public MyDataStructure(T[] items)
    {
        _items = items;
    }

    public IEnumerator<T> GetEnumerator()
    {
        foreach (var item in _item...
senior

senior

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

middle

What is the use of the IDisposable interface?

junior

What are Reference Types in C#?

junior

How is Exception Handling implemented in C#?

Bình luận

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

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