using System; using System.IO; using System.Linq; namespace test { class Program { static void Main(string[] args) { StreamReader _srFile_ = new StreamReader("file.txt"); while (!_srFile_.EndOfStream) { string _cLine_ = _srFile_.ReadLine(); int num = int.Parse(_cLine_.Substring(7, _cLine_.IndexOf(' ') - 7)); Console.Write("Number: " + num); // TODO: add num to database _cLine_ = _cLine_.Substring(_cLine_.IndexOf(' ') + 1); do { string alphabet; alphabet = (_cLine_.Contains(' ')) ? _cLine_.Substring(9, _cLine_.IndexOf(' ') - 9) : _cLine_.Substring(9, _cLine_.Length - 9); // TODO: add alphabet to database Console.Write(" Alphabet: " + alphabet); if (!_cLine_.Contains(' ')) { _cLine_ = string.Empty; break; } _cLine_ = _cLine_.Substring(_cLine_.IndexOf(' ') + 1); } while (_cLine_.Length > 0); Console.WriteLine(); } Console.ReadLine(); _srFile_.Close(); } } }