我们如何使用`params object [] args`将可变数量的params封装到另一种方法上?

时间:2019-05-02 02:51:46

标签: c# .net-core

official docs page中没有示例。

public class MyClass
{
    public static void Foo(params int[] args)
    {
        Bar(args) // error (I want to automatically pass args e.g.: Bar(args[0], args[1], args[2]...))
    }

    public static int Bar(int a, int b, int c, int d, int e) {
        return a + b + c + d + e;
    }

}


2 个答案:

答案 0 :(得分:0)

您可以在下面简单地做

public static void Foo(params int[] args)
        {
            Bar(args); // error (I want to automatically pass args e.g.: Bar(args[0], args[1], args[2]...))
        }
        public static int Bar(params int [] values)
        {
            int total = 0;
            foreach (int value in values)
            {
                total += value;
            }
            return total;
            //return a + b + c + d + e;
        }

答案 1 :(得分:0)

# (list) Application requirements
requirements = python3,kivy,setuptools,libffi,web3,eth-account,cytoolz


05-04 02:24:24.261 13540 13563 I python  :    File "/home/wangyc/.buildozer/android/platform/build/build/python-installs/myapp/cytoolz/__init__.py", line 1, in <module>
05-04 02:24:24.264 13540 13563 I python  :  ImportError: dlopen failed: "/data/data/org.test.myapp/files/app/_python_bundle/site-packages/cytoolz/itertoolz.so" is 64-bit instead of 32-bit
05-04 02:24:24.264 13540 13563 I python  : Python for android ended.