相关疑难解决方法(0)

如何使用未指定数量的参数构建一个方法C#

这是我的代码:

    private static string AddURISlash(string remotePath)
    {
        if (remotePath.LastIndexOf("/") != remotePath.Length - 1)
        {
            remotePath += "/";
        }
        return remotePath;
    }
Run Code Online (Sandbox Code Playgroud)

但我需要类似的东西

AddURISlash("http://foo", "bar", "baz/", "qux", "etc/");
Run Code Online (Sandbox Code Playgroud)

如果我没记错的话,string.format就是那样......

String.Format("{0}.{1}.{2}.{3} at {4}", 255, 255, 255, 0, "4 p.m.");
Run Code Online (Sandbox Code Playgroud)

C#中有什么东西允许我这样做吗?

我知道我能做到

private static string AddURISlash(string[] remotePath)
Run Code Online (Sandbox Code Playgroud)

但那不是主意.

如果这是某些框架中的某些内容可以完成而在其他框架中没有请指定以及如何解决它.

提前致谢

c# parameters

4
推荐指数
2
解决办法
238
查看次数

标签 统计

c# ×1

parameters ×1