我在字符串FindCardMetaData()上遇到问题,它显示了Expected; 或=(不能在声明中指定构造函数参数)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using KanbanAddIn.KanbanMetadataService;
namespace KanbanAddIn
{
public class KanbanCard
{
static void Main(string[] args)
{
const string USER_ID = "niket";
KanbanMetadataService.iformPortTypeClient MetadataClient = new iformPortTypeClient("iformServiceSOAP11port");
string FindCardMetaData()
{
MetadataClient.getCardMetadata(new getCardMetadata_Input()
{
userLoginId = USER_ID,
cardType = "KanbanDefect"
});
return "";
}
}
}
}
错误屏幕截图:
答案 0 :(得分:0)
它只是语法错误,你不能在另一个方法中声明方法。这是编译器友好的代码:
public class KanbanCard
{
static void Main(string[] args)
{
const string USER_ID = "niket";
var cardMetadata = FindCardMetaData(USER_ID);
}
static KanbanAddIn.KanbanMetadataService.getCardMetadata_Response FindCardMetaData(string userId)
{
KanbanMetadataService.iformPortTypeClient MetadataClient = new iformPortTypeClient("iformServiceSOAP11port");
return MetadataClient.getCardMetadata(new getCardMetadata_Input()
{
userLoginId = userId,
cardType = "KanbanDefect"
});
}
}
答案 1 :(得分:0)
你不能在这里声明一个函数:
string FindCardMetaData()
{
MetadataClient.getCardMetadata(new getCardMetadata_Input()
{
userLoginId = USER_ID,
cardType = "KanbanDefect"
});
return "";
}
把它放在班级的其他地方。