What interface should your data structure...
What interface should your data structure...
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
Gợi ý câu hỏi phỏng vấn
Chưa có bình luận nào