ERLEDIGT
NEIN
NEIN
ANTWORTEN
0
0
ZUGRIFFE
388
388
EMPFEHLEN
-
30.12.06 18:54 #1
- Registriert seit
- Jun 2002
- Ort
- Saarbrücken (Saarland)
- Beiträge
- 9.886
- Blog-Einträge
- 29
Hallo!
Schaut mal hier:
Code csharp:1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
using System; using System.Collections.Generic; using System.Text; using System.IO; namespace De.Tutorials.Training { public class TextFileReaderExample { public static void Main(string[] args) { foreach(string line in new TextFile(@"c:\zitate.txt")){ Console.WriteLine(line); } } } class TextFile : IEnumerable<string> { string pathToFile; public TextFile(string pathToFile) { this.pathToFile = pathToFile; } #region IEnumerable<string> Members public IEnumerator<string> GetEnumerator() { StreamReader streamReader = File.OpenText(this.pathToFile); using (streamReader) { string line; while (null != (line = streamReader.ReadLine())) { yield return line; } } } #endregion #region IEnumerable Members System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { return this.GetEnumerator(); } #endregion } }
Gruß TomJava rocks!
How to become a good Java Programmer?
Does IT in Java and .Net
The only valid measurement of code quality: WTFs / minute
Blog
Xing
Twitter
Ähnliche Themen
-
auslesen einer textdatei und in eine neue textdatei schreiben
Von prinzessin4444 im Forum C/C++Antworten: 3Letzter Beitrag: 10.12.08, 12:01 -
Anhand von SqlCmd eine erzeugte Textdatei auslesen und in eine Tabelle schreiben
Von CMS25 im Forum Relationale DatenbanksystemeAntworten: 1Letzter Beitrag: 21.11.06, 13:36 -
Die einfache Art eine Textdatei einzulesen
Von Thomas Darimont im Forum JavaAntworten: 0Letzter Beitrag: 27.09.06, 22:12 -
Eine einfache Frage ...
Von Alexander12 im Forum HTML & XHTMLAntworten: 4Letzter Beitrag: 26.08.05, 18:39 -
einfache Textdatei
Von Abbreviation im Forum VisualStudio & MFCAntworten: 2Letzter Beitrag: 22.09.04, 11:27






Zitieren
Login





