Cannot convert method group to string error

1.6k views Asked by At

A little green when it comes to C# so I would really appreciate some help on this. 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

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

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. My data is separated by a semicolon in the text file and I have it shown as [FileHelpers.DelimitedRecord(";")]. Ive looked this up on FileHelpers and it looks to me like Im doing it right. http://www.filehelpers.net/quickstart/ A little help would be much appreciated.

1

There are 1 answers

0
Marcos Meli On

You must use data in the ReadString method:

    //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/