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:

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

senior

What is the difference between System.ApplicationException class and System.SystemException class?

junior

What is Managed or Unmanaged Code?

senior

What is difference between late binding and early binding in C#?

Bình luận

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

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