user943194
user943194

Reputation:

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 arguments"

Upvotes: 0

Views: 303

Answers (7)

Cubicle.Jockey
Cubicle.Jockey

Reputation: 3328

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

Upvotes: 1

sll
sll

Reputation: 62484

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

Upvotes: 7

Tejs
Tejs

Reputation: 41236

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>>

Upvotes: 1

Chris Shain
Chris Shain

Reputation: 51319

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>>

Upvotes: 1

DeCaf
DeCaf

Reputation: 6086

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.

Upvotes: 1

x0n
x0n

Reputation: 52410

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

Upvotes: 1

asawyer
asawyer

Reputation: 17808

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

IEnumerable<string, T>

What exactly are you trying to accomplish?

Upvotes: 1

Related Questions