Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/336.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/email/3.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#_Combobox - Fatal编程技术网

C# 组合框中需要标识符

C# 组合框中需要标识符,c#,combobox,C#,Combobox,cboMethod.DataSource=Enum.GetNames(typeof(Method)) 在方法之后。是一条小红线,表示需要标识符。“我的组合框”中的选定项应为该标识符。我做错了什么?您不能像那样动态访问枚举成员。在这种情况下,您可能需要使用: @你不应该通过编辑来回复答案。这就是注释的目的。很抱歉,我无法在错误>错误1“Mollie.Api.Method”周围找到“黄色框”,它是一个“类型”,但被用作“变量”>Error 2“System.Enum.Parse(System.typ

cboMethod.DataSource=Enum.GetNames(typeof(Method))


方法之后。
是一条小红线,表示需要标识符。“我的组合框”中的选定项应为该标识符。我做错了什么?

您不能像那样动态访问枚举成员。在这种情况下,您可能需要使用:


@你不应该通过编辑来回复答案。这就是注释的目的。很抱歉,我无法在错误>错误1“Mollie.Api.Method”周围找到“黄色框”,它是一个“类型”,但被用作“变量”>Error 2“System.Enum.Parse(System.type,string)的最佳重载方法匹配项”'有一些无效参数>错误3参数1:无法从'Mollie.Api.Method'转换为'System.Type'@extreme4all我在3分钟前编辑了答案以解决该问题。我只是忘了添加
typeof(…)
对不起,您不能这样做“;“必须是”,“错误1无法将类型“object”隐式转换为“Mollie.Api.Method?”。存在显式转换(是否缺少一个转换?@extreme4all看起来我也缺少一个转换。修好了。
Console.WriteLine("Starting payment with a specific method ...");
status = mollieClient.StartPayment(new Payment
{
amount = decimal.Parse(lblPrijs.Text),
method = Method.(cboMethod.SelectedItem.ToString()),
description = "Test payment",
redirectUrl = "http://www.lynx-automation.be/"
});
Console.WriteLine("Starting payment with a specific method ...");
status = mollieClient.StartPayment(new Payment
{
    amount = decimal.Parse(lblPrijs.Text),
    method = (Method)Enum.Parse(typeof(Method), cboMethod.SelectedItem.ToString()),
    description = "Test payment",
    redirectUrl = "http://www.lynx-automation.be/"
});