Generic variadic parameters

后端 未结 1 858
攒了一身酷
攒了一身酷 2020-12-31 17:31

From dahlbyk answer to this question : Map two lists into a dictionary in C# , Leppie wrote this comment:

Pity there is a need for a Zip method. If only
相关标签:
1条回答
  • 2020-12-31 18:17

    He means, that if C# would support dynamic number or arguments (variadic, params) which are all of a different generic type, there wouldn't be a need for a Zip method, because it could be covered by Select.

    I don't know if this is true, just interpreting the sentence ...

    Edit:

    I just think that he means a variable number of generic types (which is in fact only useful in combination with a variable number of method arguments), like this:

    void Foo<params T>(params T[] args)
    
    Foo(true, 7, "hello");
    

    Just think about the many declarations of Action<...> and Func<...>.

    By the way, when you are not sure about a comment, why not simply asking him?

    0 讨论(0)
提交回复
热议问题