简体   繁体   English

无法将方法组转换为字符串错误

[英]Cannot convert method group to string error

A little green when it comes to C# so I would really appreciate some help on this.在 C# 方面有点绿色,所以我真的很感激这方面的一些帮助。 I keep getting this error on this part of my code.我在代码的这一部分不断收到此错误。

Error 1 The best overloaded method match for 'FileHelpers.FileHelperEngine.ReadString(string)' has some invalid arguments C:\\Users\\Traci\\Documents\\Visual Studio 2013\\Projects\\SpectraMX\\src\\SpectraMX.app\\Program.cs 26 45 SpectraMX.app错误 1 ​​'FileHelpers.FileHelperEngine.ReadString(string)' 的最佳重载方法匹配有一些无效参数 C:\\Users\\Traci\\Documents\\Visual Studio 2013\\Projects\\SpectraMX\\src\\SpectraMX.app\\Program.cs 26 45 SpectraMX.app

static void Main(string[] args)
    {
        //get data from my ftp site
        string data = getDataFromFtpSite();

        //go through the records there
        FileHelperEngine <FtpProductRecord> engine = new FileHelperEngine<FtpProductRecord>();

        FtpProductRecord[] FtpRecords = engine.ReadString(getDataFromFtpSite);

        //for record requested below, write it

        foreach (var product in FtpRecords)
        {
            Console.WriteLine(product._UPC);
        }

The second error I get is:我得到的第二个错误是:

Error 2 Argument 1: cannot convert from 'method group' to 'string' C:\\Users\\Traci\\Documents\\Visual Studio 2013\\Projects\\SpectraMX\\src\\SpectraMX.app\\Program.cs 26 63 SpectraMX.app错误 2 参数 1:无法从“方法组”转换为“字符串” C:\\Users\\Traci\\Documents\\Visual Studio 2013\\Projects\\SpectraMX\\src\\SpectraMX.app\\Program.cs 26 63 SpectraMX.app

When I run without debugging as is, I'm getting ALL of the data in the text file instead of just the UPC portion of it I requested.当我在没有调试的情况下运行时,我得到了文本文件中的所有数据,而不仅仅是我请求的 UPC 部分。 My data is separated by a semicolon in the text file and I have it shown as [FileHelpers.DelimitedRecord(";")].我的数据在文本文件中用分号分隔,我将其显示为 [FileHelpers.DelimitedRecord(";")]。 Ive looked this up on FileHelpers and it looks to me like Im doing it right.我在 FileHelpers 上查过这个,在我看来,我做对了。 http://www.filehelpers.net/quickstart/ A little help would be much appreciated. http://www.filehelpers.net/quickstart/一点帮助将不胜感激。

You must use data in the ReadString method:您必须在 ReadString 方法中使用数据:

    //get data from my ftp site
    string data = getDataFromFtpSite();

    //go through the records there
    var engine = new FileHelperEngine<FtpProductRecord>();

    var FtpRecords = engine.ReadString(data);

    //for record requested below, write it

    foreach (var product in FtpRecords)
    {
        Console.WriteLine(product._UPC);
    }

I recommend to update to last version of the library at我建议更新到最新版本的库

http://www.filehelpers.net/download/ http://www.filehelpers.net/download/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM