none
Die Methodengruppe "ReadToEnd" kann nicht in den Nichtdelegattyp "string" konvertiert werden. RRS feed

  • Frage

  • Hallo Leute,
    ich habe ein Problem mit folgendem Cod, ich kann den Text nicht in "content" speichern

                if (File.Exists(strPfad))
                {
                    string content = string.Empty;
                    StreamReader myfile = new StreamReader(strPfad);
                    content = myfile.ReadToEnd;
    
                }
    Folgende Fehlermeldung:

    Die Methodengruppe "ReadToEnd" kann nicht in den Nichtdelegattyp "string" konvertiert werden. Wollten Sie die Methode aufrufen?   


    Montag, 14. Mai 2012 11:32

Antworten

Alle Antworten

  • Ups dummer Fehler hab die Klammern nach ReadToEnd nicht gesehen.
    Montag, 14. Mai 2012 11:34
  • Hallo Florian,

    ReadToEnd ist eine Methode und die wird mit () aufgerufen. Also evtl. ist es einfach schon
    content = myfile.ReadToEnd();

    Mit den besten Grüßen,

    Konrad


    Montag, 14. Mai 2012 11:34

  • Florian,

    da Du eine methode aufrufst, musst Du am Ende noch zwei Klammern hinzufügen.

    content = myfile.ReadToEnd();

    Hannes

    If you have got questions about this, just ask.

    In a perfect world,
    users would never enter data in the wrong form,
    files they choose to open would always exist
    and code would never have bugs.

    C# to VB.NET: http://www.developerfusion.com/tools/convert/csharp-to-vb/

    Montag, 14. Mai 2012 11:35