Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/276.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 函数具有无效参数_C# - Fatal编程技术网

C# 函数具有无效参数

C# 函数具有无效参数,c#,C#,我觉得这应该是一个简单的概念;然而,我似乎错过了一些东西。 我收到错误“test.rawr(String[])的最佳重载方法匹配有一些无效参数” 有什么想法吗?我有一种感觉,我错过了一些非常基本的东西 我有一个传递URL的函数,处理该URL,并执行正常的“工作” 代码如下: public int very_very_sad() { rawr("My-Url_here"); } public static void rawr(string[] args) { } 谢谢 您的函数

我觉得这应该是一个简单的概念;然而,我似乎错过了一些东西。 我收到错误“test.rawr(String[])的最佳重载方法匹配有一些无效参数”

有什么想法吗?我有一种感觉,我错过了一些非常基本的东西

我有一个传递URL的函数,处理该URL,并执行正常的“工作” 代码如下:

    public int very_very_sad()
{

    rawr("My-Url_here");
}
public static void rawr(string[] args)
{
}

谢谢

您的函数只接受字符串[],但您正在传递一个字符串

更改您的功能如下:

public int very_very_sad()
{    
    rawr("My-Url_here");
}
public static void rawr(string args)
{
}

函数只接受字符串[],但传递的是字符串

更改您的功能如下:

public int very_very_sad()
{    
    rawr("My-Url_here");
}
public static void rawr(string args)
{
}

您应该传递一个
string[]
,因为该方法需要
string[]
,而不仅仅是
string

这样做:

 rawr(new string[]{"My-Url_here"});

您应该传递一个
string[]
,因为该方法需要
string[]
,而不仅仅是
string

这样做:

 rawr(new string[]{"My-Url_here"});

您正在将
字符串
传递给接受
字符串[]
(字符串数组)的函数。您可能需要一个可变长度的参数列表:

public static void rawr(params string[] args)

您正在将
字符串
传递给接受
字符串[]
(字符串数组)的函数。您可能需要一个可变长度的参数列表:

public static void rawr(params string[] args)

我看到的是你应该只传递一个数组而不是一个字符串变量,我看到的是你应该传递一个数组而不是一个字符串变量。好吧,我出丑了,谢谢。好吧,谢谢,我把自己当傻瓜了。