无法转换类型&#39; System.Collections.Generic.List <int>&#39;到&#39;字符串&#39;

时间:2017-04-18 04:09:30

标签: c# .net

代码是:

public static string PrintMaterialLabelFormat(BasicParam basicParam, List<PrintLabelFormatInfo> printLabelDataList)
{
    LabelPrintServiceClient service = new LabelPrintServiceClient();         
    try         
    {
        string output = service.PrintMaterialLabelFormat(basicParam,printLabelDataList);                            
        service.Close();           
        return output;
    }         
    catch
    {
        service.Abort();
        throw;
    }
}

2 个答案:

答案 0 :(得分:1)

显然

sys.modules

会返回一个整数列表,而不是service.PrintMaterialLabelFormat(basicParam,printLabelDataList);

答案 1 :(得分:0)

如果返回类型为service.PrintMaterialLabelFormat(basicParam,printLabelDataList)List<int>使用

string output = Convert.ToString(service.PrintMaterialLabelFormat(basicParam,printLabelDataList).FirstOrDefalut());

它将解决类型错误,但我认为您应该考虑代码中的一些更改