开发者

Generic Interface, IEnumerable

I Have the following code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace QQQ.Mappings
{
    interface IExcess<T>
    {
        IEnumerable<string, T> getExcessByMaterialGroup(T[] data);
        void Sort<TKey>(T[] data, Func<T, TKey> selector);
    }
}

But I'm getting this error, "Using the generic type 'System.Collections.Generic.IEnumerable' requires '1' type arg开发者_Go百科uments"


There is no standard IEnumerable<T, K> generic type interface, only IEnumerable<T> (MSDN). I believe you are need IDictionary<string, T> (MSDN) instead


You are attempting to return IEnumerable<string, T> from getExcessByMaterialGroup. IEnumerable<T> only takes one type parameter, not two (String and T). My guess is that you want to return something like IEnumerable<KeyValuePair<String, T>>


This is your problem, IEnumerable has only 1 generic argument.

IEnumerable<string, T>

What exactly are you trying to accomplish?


IEnumerable only accepts a single type argument. You should be declaring that as IEnumerable<T>.


IEnumerable only has one type argument, yet you have specified two (string, T). You probably want something like:

IEnumerable<string> getExcessByMaterialGroup(T[] data);

if the method is supposed to return an enumerable of strings.


IEnumerable<T> exists, there is no dual dictionary style IEnumerable<T, U>.

If you're looking for a KeyValue like relationship, consider IEnumerable<KeyValuePair<string, T>>


IEnumerable<T> is the only method there is no IEnumerable<T,T> but you can use IDictionary<T,T>

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜