• Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.
    To learn more about how to use our BBCode feature, please click here.

    Thank you, Code Forum.

C# filling up record list from text file


New Coder
I try to fill up a record list that works in a previous code but it don't in the current one. what is strange the loop while doesn't look running at all, so filing up record list from text file posted also doesn't happen. also it is a problem the beginning of the text file. it starts with a code. I try to get it also but running the code noting happens, noting is running. no error msg Please have a look and help me as it is possible.
the code:

 string olvas = @"c:\Users\Public\textfiles\pitypang.txt";
            List<pitypang00> adatok = new List<pitypang00>();
            int i = 0;
            int i2 = 0;
            int kod0 = 0;
            int utolso = 0;
                // Open the text file using a stream reader.
                using (var sr = new StreamReader(olvas, Encoding.Default))
                    // Read the stream as a string, and write the string to the console.
                    while (!sr.EndOfStream)

                        string sor = sr.ReadLine();
                        string[] record = sor.Split(' ');

                        adatok.Add(new pitypang00());
                        if (i == 0) { kod0 = Convert.ToInt32(record[0]); }
                            adatok[i].foglaloszam = Convert.ToInt32(record[1]);
                            adatok[i].szobaszam = Convert.ToInt32(record[2]);
                            adatok[i].erkezesinapsorszama = Convert.ToInt32(record[3]);
                            adatok[i].tavozasinapsorszam = Convert.ToInt32(record[4]);
                            adatok[i].vendegszam = Convert.ToInt32(record[5]);
                            adatok[i].kernekreggelit = Convert.ToInt32(record[6]);
                            adatok[i].vendegazonosito = record[7];
                            Console.WriteLine(i+" "+ record[7]);
                    for (i2 = 1; i2 <= utolso; i2++){
                            " Foglaloszam  "+ adatok[i].foglaloszam+
                            " Szobaszam    "+ adatok[i].szobaszam+
                            " Erkezesinap\n sorszama "+ adatok[i].erkezesinapsorszama);


  • pitypang.txt
    31.8 KB · Views: 0