Reputation: 69
is it possible to do an extension for a specific type of list?
Like a calculate function only for List<int>
?
I tried something like
public static void addTag<TagInfos>(this List<TagInfos> list,
zeiterfassungsdatensatz ds){
//some code
}
this. in this example i tried to create a extension addTag(zeiterfassungsdatensatz) to all List<TagInfos>
. This function is usable at all my Lists. But i dont want this.
Is it possible?
Greets
Upvotes: 1
Views: 43
Reputation: 460098
Then you don't need a generic extension:
public static void addTag(this List<TagInfos> list, zeiterfassungsdatensatz ds)
{
// ...
}
But you could also use a constraint:
public static void addTag<T>(this List<T> list, zeiterfassungsdatensatz ds)
where T: TagInfos
{
}
Upvotes: 1