Question trying to build a list of temperatures - datastrucure needed for count

cfrank2000

Well-known member
Joined
Mar 6, 2021
Messages
71
Programming Experience
Beginner
metjelentes:
using System;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;

namespace metjelentes
{
    using System;
    class mystruct
    {
        public string telepulesKod { get; set; }
        public string[] mertErtekek { get; set; }
        public string[] ertekek { get; set; }
        public int atlaghm { get; set; }
        public int Minhm { get; set; }
        public int Maxhm { get; set; }
    }
    class adatok0
    {
        public string telepules { get; set; }
        public string ido { get; set; }
        public string szeliranyes_erosseg { get; set; }
        public int homerseklet { get; set; }
        public int sorszam { get; set; }
    
        public int ertekek { get; set; }
   }

    class beolvasas
    {
        int db = -1;
        string ido = "";
        string utolsomeres = "";
        
        int kertszam = 0;
        int maxhom = 0;
        public int minhom = 0;
        int hom = 0;
        int maxindex = 0;
        int hossz = 0;
        string kerttelepules = "";
        public List<adatok0> lista = new List<adatok0>();
        public List<int> homersekletlista = new List<int>();
        public List<string> telepulesek = new List<string>();
        public List<string[]> idopont = new List<string[]>(2);
        public void beolvas()
        {

            string olvas = @"c:\Users\Public\textfiles\tavirathu13.txt";
            using (StreamReader sr = new StreamReader(olvas, Encoding.Default))
            {
                //StreamReader sr = new StreamReader(olvas, Encoding.Default);

                //List<adatok> lista = new List<adatok>();

                while (!sr.EndOfStream)
                {
                    string[] sor = sr.ReadLine().Split(' ');
                    //string[] elemek = sor.Split(' ');
                    adatok0 adat = new adatok0();

                    adat.telepules = sor[0];
                    adat.ido = sor[1];
                    adat.szeliranyes_erosseg = sor[2];
                    adat.homerseklet = Int32.Parse(sor[3]);
                    lista.Add(adat);
                    db++;
                    adat.sorszam = db;
                }
                Random rd = new Random();
                kertszam = rd.Next(1, db);
                hossz = db;
            }
        }
        public void szamol()
        {
            int n = -1;
            foreach (adatok0 dt in lista)
            { n++;
                if (n == kertszam)
                {

                    kerttelepules = dt.telepules;
                    ido = dt.ido;

                }
                

            }
            n = 0;
            int m = 0;
            foreach (adatok0 dt in lista)
            {
                //m++;
                //maxindex = m;
                if (lista[kertszam].telepules == dt.telepules)
                {
                    ido = dt.ido;
                   // Console.WriteLine(" m " + m + " telepules " + kerttelepules + "  " + ido + " " + hom);
                    hom = dt.homerseklet;
                    homersekletlista.Add(hom);
                    homersekletlista.Sort();
                }
                utolsomeres = ido;
            }
            //Console.WriteLine(" n " + n + " ido " + utolsomeres);

        
        foreach (int ct in homersekletlista)
            {
                //Console.WriteLine(" homerseklet " +ct);
                maxhom = ct;
            }
            minhom = homersekletlista[0];
            //Console.WriteLine(" min  homersekle   " + minhom);
            //maxhom = homersekletlista[maxindex-1];//
            //Console.WriteLine(" max  homersekle   " + maxhom);
           /*
          
            /*       */
            }
        //List<int> a = new List<int>();
        int[] a2 = new int[900];
        int i = 0;
        int j = 0;
        int k = -1;
        
        string[] tomb = new string[900];
        List<mystruct> tmb2 = new List<mystruct>();
        List<int> lst1 = new List<int>();
        List<int> lst2 = new List<int>();
        int[,] Vektor = new int[100, 400];

        // hossz = str1.Length;

        public void valogat()
        {
            for (i = 0; i < hossz; i++)
            {
                for (j = 0; j < hossz; j++)
                {
                    if (lista[j].telepules == lista[i].telepules)
                    {

                        a2[j] += 1;
                        if (a2[j] < 2)
                        {
                            //mystruct myrek = new mystruct();
                          
                            //tomb[i] = Convert.ToString(str1[i]);
                           // myrek.kar = lista[j].telepules;
                            
                            k = k + 1;
                            tomb[i]= lista[i].telepules;
                          
                        }
                        else
                        {
                            tomb[i] = "empty";
                        }

                    }
                   // Console.WriteLine(" " + tomb[i]);
                }
                //Console.WriteLine(" tomb[ " + i + " ] " + tomb[i]);
            }
            Console.WriteLine(db + " db ");
            for (i=0;i<db;i++)
            {
                //Console.WriteLine(db + " tomb[ " + i + " ] " + tomb[i]);
                if (tomb[i] != "empty")
                {
                    mystruct mydata1 = new mystruct();
                    mydata1.telepulesKod = tomb[i];
                    Console.WriteLine(" "+db+ " tomb[ " + i + " ] " + mydata1.telepulesKod);
                    tmb2.Add(mydata1);
                    if (lista[j].ido.Substring(0, 2) == ora[l].ToString() == true)
                    {
                        if (lista[j].homerseklet > 0)
                        {

                           // Console.Write(lista[j].ido.Substring(0, 2) + " ora " + lista[j].homerseklet + " fok ");
                            Vektor[i, j] = lista[j].homerseklet;
                            lst1.Add(Vektor[i, j]);


                        }

                    }

                }
            }
                
            
            foreach (mystruct dt3 in tmb2)
            {
                Console.WriteLine(" tmb2[ ] " + dt3.telepulesKod);
            }

        }

        int[] ora = new int[4] { 1, 7, 13, 19 };
        int l = 0;
        //List<int[,]> vektor = new List<int[,]>();
      

        public void meresek()
        {
            Console.WriteLine(" 1 ");
            Console.WriteLine(" tmb2 " + tmb2.Count);
            Console.WriteLine(" 2 ");
            for (int i3=0;i3< tmb2.Count; i3++)
                {
                Console.WriteLine("  ");
                Console.WriteLine("  " + tmb2.Count +"  "+ tmb2[i3].telepulesKod);
                Console.WriteLine("  ");
                for (j = 0; j < db; j++)
                    {

                        if (tmb2[i3].telepulesKod == lista[j].telepules)
                        {
                           // Console.Write(" " + lista[j].homerseklet);
                        for (l=0;l<4;l++)
                        {
                        /* */   
                            if (lista[j].ido.Substring(0, 2)==ora[l].ToString() == true)
                            {
                                if (lista[j].homerseklet > 0 )
                                {
                                   mystruct rek1 = new mystruct;
                                    List<adatok0> mert1 = new List<adatok0>();
                               // mystruct merthom = new mystruct();
                                    //Console.Write(" j "+j+" "+lista[j].ido.Substring(0, 2) + " ora " + lista[j].homerseklet + " fok ");
                                    Console.Write( "  " + lista[j].homerseklet + " fok ");
                                    Vektor[i3, j] = lista[j].homerseklet;
                                    lst1.Add(Vektor[i3, j]);
                                    rek1.ertekek[j] = lista[j].homerseklet;
                                    mert1[].ertekek.Add(lista[j].homerseklet.ToString());


                                }
                                //Console.Write("  ");
                            }
                                                      
                        }
                        
                        }
                  
                    }
                //Console.WriteLine(" ");
                

            }
            Console.WriteLine(" ");
           // foreach (int a1 in lst1)
           // {
               // Console.Write("   " + a1);

          //  }
          ///  lst1.Clear();
        }
        int i1 = 0;
        int j1 = 0;
        public void kiiras()
        {
            /*
            for (i1 = 0; i1 < 100; i1++)
            {
                for (j1 = 0; j1 < db; j1++)
                    { if (Vektor[i1, j1] != 0)
                        {
                            //Array.Sort();
                            Console.Write(" v " + Vektor[i1, j1]);
                        }
                     }
                Console.WriteLine("  ");
            }
            */
            for (int i = 0; i<db; i++)
                {
                    Console.WriteLine(" ");
                // rekordlista adat = new rekordlista();
              
                Console.WriteLine(
                         " Sorszam   " + lista[i].sorszam +
                         " Telepules " + lista[i].telepules +
                         " Ido   " + lista[i].ido +
                         " Szelirany es_erosseg " + lista[i].szeliranyes_erosseg +
                         " Homerseklet " + lista[i].homerseklet
                        );

                    //fordulo = fordulo + Int32.Parse(rlista[i].fordulo);
                    //telitalalatok = telitalalatok + Int32.Parse(rlista[i].Ndarab13p1talalat);
                    //osszeg = osszeg + rlista[i].ossznyeremeny;

                }
            Console.WriteLine(" A rekordok szama db " + db);
            Console.WriteLine("  2. Feladat ");
            Console.WriteLine("     A kert kod " + kertszam + " Telepules " + lista[kertszam].telepules+ " Ido   " + lista[kertszam].ido);
            Console.WriteLine("     A kert telepules kod " + kerttelepules);
            Console.WriteLine("     Az utolso meresi adat   " + utolsomeres);
            Console.WriteLine("  3. Feladat ");
            Console.WriteLine("     A mert homerseklet maximum "+maxhom+ " Minimum homerseklet "+minhom);
            Console.WriteLine("  4. Feladat ");
            foreach (adatok0 dt in lista )
            {
                if ("00000" == dt.szeliranyes_erosseg)
                {
                    Console.WriteLine("     szelcsend " + dt.telepules+" "+dt.ido);
                }
            }
            Console.WriteLine("  5. Feladat ");
            Console.WriteLine("     Szereplo Telepulesek kodja ");
            foreach (mystruct dt3 in tmb2)
            {
                Console.WriteLine("     Az adott Telepules " + dt3.telepulesKod);
            }
        }
        }
    
       class Program
        {
            static void Main(string[] args)
            {
            beolvasas kiir1 = new beolvasas();
            kiir1.beolvas();
            kiir1.szamol();
            kiir1.valogat();
            kiir1.meresek();
            kiir1.kiiras();
            //Console.WriteLine("Hello World!");
        }
        }
}
 
What's the conversion problem you are running into?
the conversion problem is to read out an int from int array to an int. to be honest I try to read data in an array from Vektor[i3,j] and that is where I get error msg. if that is working , I have a data structure that helps me to make txt files with city code and content as required, mean temperature, max and min temperature. it looks so I can not use neither List nor array in dictionary as value, I don't understand it. also an array have to have a number for size, if I try indirectly using an integer , it is not allowed , can I get help with it?. thank you
 
Last edited:
What error message are you getting when you try to read an integer from a two dimensional integer array? Seems to me like there is very little chance of there being a conversion error since an array of integers already contains integers.

It's not clear to me why you need to put things into a two dimensional array before writing out the data to a text file. Why do you need that intermediate step? Why not just write what you were going to put into the array into the file?
 
to be honest I just need to get the min and max temperature and average temperature of a city code, then save each city code and its detail in txt file.
the error code lost is :

Severity Code Description Project File Line Suppression State
Error CS1002 ; expected meteoreport1 C:\Users\Dell\source\repos\meteoreport1\meteoreport1\Program.cs 242 Active
Error CS1503 Argument 2: cannot convert from 'int' to 'int[]' meteoreport1 C:\Users\Dell\source\repos\meteoreport1\meteoreport1\Program.cs 243 Active
Error CS8400 Feature 'top-level statements' is not available in C# 8.0. Please use language version 9.0 or greater. meteoreport1 C:\Users\Dell\source\repos\meteoreport1\meteoreport1\Program.cs 264 Active
Warning CS8321 The local function 'displaying' is declared but never used meteoreport1 C:\Users\Dell\source\repos\meteoreport1\meteoreport1\Program.cs 274 Active
Error CS0106 The modifier 'public' is not valid for this item meteoreport1 C:\Users\Dell\source\repos\meteoreport1\meteoreport1\Program.cs 274 Active
Error CS0103 The name 'i3' does not exist in the current context meteoreport1 C:\Users\Dell\source\repos\meteoreport1\meteoreport1\Program.cs 243 Active
Error CS0103 The name 'i3' does not exist in the current context meteoreport1 C:\Users\Dell\source\repos\meteoreport1\meteoreport1\Program.cs 244 Active
Error CS0103 The name 'i3' does not exist in the current context meteoreport1 C:\Users\Dell\source\repos\meteoreport1\meteoreport1\Program.cs 246 Active
Error CS0103 The name 'lastmeasures' does not exist in the current context meteoreport1 C:\Users\Dell\source\repos\meteoreport1\meteoreport1\Program.cs 311 Active
Error CS0103 The name 'list1' does not exist in the current context meteoreport1 C:\Users\Dell\source\repos\meteoreport1\meteoreport1\Program.cs 295 Active
Error CS0103 The name 'list1' does not exist in the current context meteoreport1 C:\Users\Dell\source\repos\meteoreport1\meteoreport1\Program.cs 296 Active
Error CS0103 The name 'list1' does not exist in the current context meteoreport1 C:\Users\Dell\source\repos\meteoreport1\meteoreport1\Program.cs 297 Active
Error CS0103 The name 'list1' does not exist in the current context meteoreport1 C:\Users\Dell\source\repos\meteoreport1\meteoreport1\Program.cs 298 Active
Error CS0103 The name 'list1' does not exist in the current context meteoreport1 C:\Users\Dell\source\repos\meteoreport1\meteoreport1\Program.cs 299 Active
Error CS0103 The name 'list1' does not exist in the current context meteoreport1 C:\Users\Dell\source\repos\meteoreport1\meteoreport1\Program.cs 309 Active
Error CS0103 The name 'list1' does not exist in the current context meteoreport1 C:\Users\Dell\source\repos\meteoreport1\meteoreport1\Program.cs 309 Active
Error CS0103 The name 'list1' does not exist in the current context meteoreport1 C:\Users\Dell\source\repos\meteoreport1\meteoreport1\Program.cs 315 Active
Error CS0103 The name 'maxtempr' does not exist in the current context meteoreport1 C:\Users\Dell\source\repos\meteoreport1\meteoreport1\Program.cs 313 Active
Error CS0103 The name 'mintepr' does not exist in the current context meteoreport1 C:\Users\Dell\source\repos\meteoreport1\meteoreport1\Program.cs 313 Active
Error CS0103 The name 'piece' does not exist in the current context meteoreport1 C:\Users\Dell\source\repos\meteoreport1\meteoreport1\Program.cs 289 Active
Error CS0103 The name 'piece' does not exist in the current context meteoreport1 C:\Users\Dell\source\repos\meteoreport1\meteoreport1\Program.cs 307 Active
Error CS0103 The name 'requiredlocality' does not exist in the current context meteoreport1 C:\Users\Dell\source\repos\meteoreport1\meteoreport1\Program.cs 310 Active
Error CS0103 The name 'requirednm' does not exist in the current context meteoreport1 C:\Users\Dell\source\repos\meteoreport1\meteoreport1\Program.cs 309 Active
Error CS0103 The name 'requirednm' does not exist in the current context meteoreport1 C:\Users\Dell\source\repos\meteoreport1\meteoreport1\Program.cs 309 Active
Error CS0103 The name 'requirednm' does not exist in the current context meteoreport1 C:\Users\Dell\source\repos\meteoreport1\meteoreport1\Program.cs 309 Active
Error CS0103 The name 'tmb2' does not exist in the current context meteoreport1 C:\Users\Dell\source\repos\meteoreport1\meteoreport1\Program.cs 324 Active
Error CS0246 The type or namespace name 'datas0' could not be found (are you missing a using directive or an assembly reference?) meteoreport1 C:\Users\Dell\source\repos\meteoreport1\meteoreport1\Program.cs 315 Active
Error CS0246 The type or namespace name 'mystruct' could not be found (are you missing a using directive or an assembly reference?) meteoreport1 C:\Users\Dell\source\repos\meteoreport1\meteoreport1\Program.cs 324 Active
Error CS0246 The type or namespace name 'reading' could not be found (are you missing a using directive or an assembly reference?) meteoreport1 C:\Users\Dell\source\repos\meteoreport1\meteoreport1\Program.cs 335 Active
Error CS0246 The type or namespace name 'reading' could not be found (are you missing a using directive or an assembly reference?) meteoreport1 C:\Users\Dell\source\repos\meteoreport1\meteoreport1\Program.cs 335 Active
Warning CS0219 The variable 'i1' is assigned but its value is never used meteoreport1 C:\Users\Dell\source\repos\meteoreport1\meteoreport1\Program.cs 272 Active
Warning CS0219 The variable 'j1' is assigned but its value is never used meteoreport1 C:\Users\Dell\source\repos\meteoreport1\meteoreport1\Program.cs 273 Active
Warning CS0219 The variable 'm' is assigned but its value is never used meteoreport1 C:\Users\Dell\source\repos\meteoreport1\meteoreport1\Program.cs 92 Active
Error CS8803 Top-level statements must precede namespace and type declarations. meteoreport1 C:\Users\Dell\source\repos\meteoreport1\meteoreport1\Program.cs 264 Active
Error CS1022 Type or namespace definition, or end-of-file expected meteoreport1 C:\Users\Dell\source\repos\meteoreport1\meteoreport1\Program.cs 257 Active
Error CS1022 Type or namespace definition, or end-of-file expected meteoreport1 C:\Users\Dell\source\repos\meteoreport1\meteoreport1\Program.cs 259 Active
Error CS1022 Type or namespace definition, or end-of-file expected meteoreport1 C:\Users\Dell\source\repos\meteoreport1\meteoreport1\Program.cs 263 Active
Error CS1022 Type or namespace definition, or end-of-file expected meteoreport1 C:\Users\Dell\source\repos\meteoreport1\meteoreport1\Program.cs 271 Active
Error CS1022 Type or namespace definition, or end-of-file expected meteoreport1 C:\Users\Dell\source\repos\meteoreport1\meteoreport1\Program.cs 329 Active
Error CS1022 Type or namespace definition, or end-of-file expected meteoreport1 C:\Users\Dell\source\repos\meteoreport1\meteoreport1\Program.cs 344 Active
Error CS1513 } expected meteoreport1 C:\Users\Dell\source\repos\meteoreport1\meteoreport1\Program.cs 242 Active
Error CS1513 } expected meteoreport1 C:\Users\Dell\source\repos\meteoreport1\meteoreport1\Program.cs 242 Active
Error CS1513 } expected meteoreport1 C:\Users\Dell\source\repos\meteoreport1\meteoreport1\Program.cs 242 Active
Error CS1513 } expected meteoreport1 C:\Users\Dell\source\repos\meteoreport1\meteoreport1\Program.cs 242 Active
Error CS1513 } expected meteoreport1 C:\Users\Dell\source\repos\meteoreport1\meteoreport1\Program.cs 242 Active
Error CS1513 } expected meteoreport1 C:\Users\Dell\source\repos\meteoreport1\meteoreport1\Program.cs 242 Active
Error CS1513 } expected meteoreport1 C:\Users\Dell\source\repos\meteoreport1\meteoreport1\Program.cs 242 Active
 
Last edited:
On the line:
C#:
measurements[i3].Add(tmb2[i3].localitycode, Vektor[i3, j]);

The error is:
C#:
CS1503    Argument 2: cannot convert from 'int' to 'int[]'

This is because measurements[i3] is a Dictionary<string, int[]>. So when you are calling Add() the first parameter should be a string, and the second parameter should be an array of integers. Vektor[i3, j] is a single integer, not an array of integers. Therefore, you are getting the error.

Why do you need a list of dictionaries?
 
On the line:
C#:
measurements[i3].Add(tmb2[i3].localitycode, Vektor[i3, j]);

The error is:
C#:
CS1503    Argument 2: cannot convert from 'int' to 'int[]'

This is because measurements[i3] is a Dictionary<string, int[]>. So when you are calling Add() the first parameter should be a string, and the second parameter should be an array of integers. Vektor[i3, j] is a single integer, not an array of integers. Therefore, you are getting the error.

Why do you need a list of dictionaries?
thank you for answer. I would like to store the date that I display because I can get min and max values, mean value. also I can display again, read required data in txt file with city code names.
 
On the line:
C#:
measurements[i3].Add(tmb2[i3].localitycode, Vektor[i3, j]);

The error is:
C#:
CS1503    Argument 2: cannot convert from 'int' to 'int[]'

This is because measurements[i3] is a Dictionary<string, int[]>. So when you are calling Add() the first parameter should be a string, and the second parameter should be an array of integers. Vektor[i3, j] is a single integer, not an array of integers. Therefore, you are getting the error.

Why do you need a list of dictionaries?
thank you. what I don't understand in dictionary matter, the first parameter is city code (string), second is an array of int. the array of int should hold the measured values for farther operations, the string the city code. can you help me please? thank you
 
I can't help you because you an int cannot hold a string city code no matter what you try to do. Furthermore, an array is a fixed size data structure. You can't add more items into the array "for farther (sic) operations".

If you don't understand how to use a dictionary, then don't use it. Just use a list that contains another data structure that contains a list. Something like this:

C#:
record Measurement
{
    public string Time { get; init; }
    public string WindDirectionAndStrength { get; init; }
    public int Temperature { get; init; }
    public int LineNumber { get; init; }
}

class LocalityData
{
    public string Locality { get; set; }
    public List<Measurement> Measurements { get; private set; }

    public string LocalityMeasurements(string locality)
    {
        Locality = locality;
        Measurements = new List<Measurement>();
    }
}

:

var localityMeasurements = new List<LocalityData>();

int lineNumeber = 1;
foreach(var line in File.ReadLines(inputFile))
{
    var columns = line.Split(' ');
    var locality = columns[0];
    var measurement = new Measurement
        {
            Time = columns[1],
            WindDirectionAndStrength = columns[2],
            Temperature = int.Parse(columns[3]),
            LineNumber = lineNumber;
        };

    var localityData = localityMeasurements.Find(lm => lm.Locality == locality);
    if (localityData == null)
    {
        localityData = new LocalityData(locality);
        localityMeasurements.Add(localityData);
    }
    localityData.Measurements.Add(measurement);
    lineNumber++;
}

foreach(var localityData in localityMeasurements)
{
    var measurements = localityData.Measurements;
    var min = measurements.Min(m => m.Temperature);
    var max = measurements.Max(m => m.Temperature);
    var ave = measurements.Average(m => m.Temperature);
    Console.Writeline($"Locality: {localityData.Locality}    Mininum:{min}    Maximum:{max}    Average:{ave}    Count:{measurements.Count}");
}
 
I can't help you because you an int cannot hold a string city code no matter what you try to do. Furthermore, an array is a fixed size data structure. You can't add more items into the array "for farther (sic) operations".

If you don't understand how to use a dictionary, then don't use it. Just use a list that contains another data structure that contains a list. Something like this:

C#:
record Measurement
{
    public string Time { get; init; }
    public string WindDirectionAndStrength { get; init; }
    public int Temperature { get; init; }
    public int LineNumber { get; init; }
}

class LocalityData
{
    public string Locality { get; set; }
    public List<Measurement> Measurements { get; private set; }

    public string LocalityMeasurements(string locality)
    {
        Locality = locality;
        Measurements = new List<Measurement>();
    }
}

:

var localityMeasurements = new List<LocalityData>();

int lineNumeber = 1;
foreach(var line in File.ReadLines(inputFile))
{
    var columns = line.Split(' ');
    var locality = columns[0];
    var measurement = new Measurement
        {
            Time = columns[1],
            WindDirectionAndStrength = columns[2],
            Temperature = int.Parse(columns[3]),
            LineNumber = lineNumber;
        };

    var localityData = localityMeasurements.Find(lm => lm.Locality == locality);
    if (localityData == null)
    {
        localityData = new LocalityData(locality);
        localityMeasurements.Add(localityData);
    }
    localityData.Measurements.Add(measurement);
    lineNumber++;
}

foreach(var localityData in localityMeasurements)
{
    var measurements = localityData.Measurements;
    var min = measurements.Min(m => m.Temperature);
    var max = measurements.Max(m => m.Temperature);
    var ave = measurements.Average(m => m.Temperature);
    Console.Writeline($"Locality: {localityData.Locality}    Mininum:{min}    Maximum:{max}    Average:{ave}    Count:{measurements.Count}");
}
yes I made mistake. I am sorry. I made changing. I have another mistake. I try to sort different line of numbers . I try to get mean value linen by line but the sort part is not working.
weather cast:
using System;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;

namespace metreport
{
    //using System;
    class mystruct
    {
        public string localitycode { get; set; }
        public string[] measuredvalue { get; set; }
        public int[] values { get; set; }
        public int sumval { get; set; }
        public int sumpiece { get; set; }
        public int meantempr { get; set; }
        public int mintempr { get; set; }
        public int maxtempr { get; set; }
    }
    class datas0
    {
        public string locality { get; set; }
        public string time { get; set; }
        public string winddirectionandstrenght { get; set; }
        public int temperature { get; set; }
        public int lineupnm { get; set; }
    
        public int values { get; set; }
   }

    class reading
    {
        int piece = -1;
        string time = ""; string lastmeasures = "";


        int requirednm = 0;
        int maxtempr = 0;
        public int mintepr = 0;
        int tempr = 0;
        int maxindex = 0;
        int lenght1 = 0;
        string requiredlocality = "";
        public List<datas0> list1 = new List<datas0>();
        public List<int> temperaturelist = new List<int>();
        public List<string> localities = new List<string>();
        public List<string[]> appointmenttime = new List<string[]>(2);
        public void read_in()
        {

            string read = @"c:\Users\Public\textfiles\tavirathu13.txt";
            using (StreamReader sr = new StreamReader(read, Encoding.Default))
            {
                //StreamReader sr = new StreamReader(olvas, Encoding.Default);

                //List<adatok> lista = new List<adatok>();

                while (!sr.EndOfStream)
                {
                    string[] row = sr.ReadLine().Split(' ');
                    //string[] elemek = sor.Split(' ');
                    datas0 data = new datas0();

                    data.locality = row[0];
                    data.time = row[1];
                    data.winddirectionandstrenght = row[2];
                    data.temperature = Int32.Parse(row[3]);
                    list1.Add(data);
                    piece++;
                    data.lineupnm = piece;
                }
                Random rd = new Random();
                requirednm = rd.Next(1, piece);
                lenght1 = piece;
            }
        }
        public void count()
        {
            int n = -1;
            foreach (datas0 dt in list1)
            { n++;
                if (n == requirednm)
                {

                    requiredlocality = dt.locality;
                    time = dt.time;

                }


            }
            n = 0;
            int m = 0;
            foreach (datas0 dt in list1)
            {
                //m++;
                //maxindex = m;
                if (list1[requirednm].locality == dt.locality)
                {
                    time = dt.time;
                    // Console.WriteLine(" m " + m + " telepules " + kerttelepules + "  " + ido + " " + hom);
                    tempr = dt.temperature;
                    temperaturelist.Add(tempr);
                    temperaturelist.Sort();
                }
                lastmeasures = time;
            }
            //Console.WriteLine(" n " + n + " ido " + utolsomeres);


            foreach (int ct in temperaturelist)
            {
                //Console.WriteLine(" homerseklet " +ct);
                maxtempr = ct;
            }
            datas0 datas11 = new datas0();
            //datas11.mintempr = temperaturelist[0];
            //Console.WriteLine(" min  homersekle   " + minhom);
            //maxhom = homersekletlista[maxindex-1];//
            //Console.WriteLine(" max  homersekle   " + maxhom);
            /*

             /*       */
        }
        //List<int> a = new List<int>();
        int[] a2 = new int[900];
        int i = 0;
        int j = 0;
        int k = -1;

        string[] tomb = new string[900];
        List<mystruct> tmb2 = new List<mystruct>();
        List<int> lst1 = new List<int>();
        List<int> lst2 = new List<int>();
        int[,] Vektor = new int[100, 400];
        int[,] Vektor2 = new int[100, 400];

        // hossz = str1.Length;

        public void select()
        {
            for (i = 0; i < lenght1; i++)
            {
                for (j = 0; j < lenght1; j++)
                {
                    if (list1[j].locality == list1[i].locality)
                    {

                        a2[j] += 1;
                        if (a2[j] < 2)
                        {
                            //mystruct myrek = new mystruct();

                            //tomb[i] = Convert.ToString(str1[i]);
                            // myrek.kar = lista[j].telepules;

                            k = k + 1;
                            tomb[i] = list1[i].locality;

                        }
                        else
                        {
                            tomb[i] = "empty";
                        }

                    }
                    // Console.WriteLine(" " + tomb[i]);
                }
                //Console.WriteLine(" tomb[ " + i + " ] " + tomb[i]);
            }
            Console.WriteLine(piece + " piece ");
            for (i = 0; i < piece; i++)
            {
                //Console.WriteLine(db + " tomb[ " + i + " ] " + tomb[i]);
                if (tomb[i] != "empty")
                {
                    mystruct mydata1 = new mystruct();
                    mydata1.localitycode = tomb[i];
                    Console.WriteLine(" " + piece + " tomb[ " + i + " ] " + mydata1.localitycode);
                    tmb2.Add(mydata1);
                    if (list1[j].time.Substring(0, 2) == ora[l].ToString() == true)
                    {
                        if (list1[j].temperature > 0)
                        {

                            // Console.Write(lista[j].ido.Substring(0, 2) + " ora " + lista[j].homerseklet + " fok ");
                            Vektor[i, j] = list1[j].temperature;
                            Vektor2[i, j].Sort(Vektor[i, j]);
                            lst1.Add(Vektor[i, j]);


                        }

                    }

                }
            }


            foreach (mystruct dt3 in tmb2)
            {
                Console.WriteLine(" tmb2[ ] " + dt3.localitycode);
            }

        }

        int[] ora = new int[4] { 1, 7, 13, 19 };
        int l = 0;
        //List<int[,]> vektor = new List<int[,]>();

        List<int> MNumbers = new List<int>();
        int[] measurementList = new int[400];
        List<Dictionary<string, int[]>> measurements = new List<Dictionary<string, int[]>>();

        public void measures()
        {
            Console.WriteLine(" help needed for datastructure ");
            Console.WriteLine(" 1 ");
            Console.WriteLine(" tmb2 " + tmb2.Count);
            Console.WriteLine(" 2 ");
            for (int i3=0;i3< tmb2.Count; i3++)
                {
                Console.WriteLine("  ");
                Console.WriteLine("  " + tmb2.Count + " tmb2[ "+ i3+ "] " + tmb2[i3].localitycode);
                Console.WriteLine("  ");
                for (j = 0; j < piece; j++)
                    {
                    
                        if (tmb2[i3].localitycode == list1[j].locality)
                        {
                           // Console.Write(" " + lista[j].homerseklet);
                        for (l=0;l<4;l++)
                        {
                        /* */   
                            if (list1[j].time.Substring(0, 2)==ora[l].ToString() == true)
                            {
                                if (list1[j].temperature > 0 )
                                {
                                   mystruct rek1 = new mystruct();
                                    List<datas0> mert1 = new List<datas0>();
                               // mystruct merthom = new mystruct();
                                    //Console.Write(" j "+j+" "+lista[j].ido.Substring(0, 2) + " ora " + lista[j].homerseklet + " fok ");
                                    Console.Write( "  " + list1[j].temperature + " degree ");
                                    Vektor[i3, j] = list1[j].temperature;
                                    //values[j] = list1[j].temperature;
                                    // measurementList[j]= Vektor[i3, j]);
                                    // measurements[i3].Add(tmb2[j].localitycode, measurementList[j]);
                                    Console.Write("  " + Vektor[i3, j] + " degree ");

                                    lst1.Add(Vektor[i3, j]);
                                   // rek1.values[j] = list1[j].temperature;
                                   // mert1[].ertekek.Add(list1[j].homerseklet.ToString());


                                }
                                //Console.Write("  ");
                            }
                                                      
                        }
                        
                        }
                  
                    }
                //Console.WriteLine(" ");
                

            }
            Console.WriteLine(" ");
           // foreach (int a1 in lst1)
           // {
               // Console.Write("   " + a1);

          //  }
          ///  lst1.Clear();
        }
        int i1 = 0;
        int j1 = 0;
        public void displaying()
        {
            /*
            for (i1 = 0; i1 < 100; i1++)
            {
                for (j1 = 0; j1 < db; j1++)
                    { if (Vektor[i1, j1] != 0)
                        {
                            //Array.Sort();
                            Console.Write(" v " + Vektor[i1, j1]);
                        }
                     }
                Console.WriteLine("  ");
            }
            */
            for (int i = 0; i<piece; i++)
                {
                    Console.WriteLine(" ");
                // rekordlista adat = new rekordlista();
              
                Console.WriteLine(
                         " Lineup number   " + list1[i].lineupnm +
                         " LOcality " + list1[i].locality +
                         " Time   " + list1[i].time +
                         " Wind dorection and strenght " + list1[i].winddirectionandstrenght +
                         " Temperature " + list1[i].temperature
                        );

                    //fordulo = fordulo + Int32.Parse(rlista[i].fordulo);
                    //telitalalatok = telitalalatok + Int32.Parse(rlista[i].Ndarab13p1talalat);
                    //osszeg = osszeg + rlista[i].ossznyeremeny;

                }
            Console.WriteLine(" Number of records " + piece);
            Console.WriteLine("  2. Task ");
            Console.WriteLine("      Requested code " + requirednm + " Locality " + list1[requirednm].locality+ " Time   " + list1[requirednm].time);
            Console.WriteLine("      Required locality code " + requiredlocality);
            Console.WriteLine("      Last measured data   " + lastmeasures);
            Console.WriteLine("  3. Task ");
            Console.WriteLine("      The measured temperature maximum "+maxtempr+ " Minimal temperature "+mintepr);
            Console.WriteLine("  4. Task ");
            foreach (datas0 dt in list1 )
            {
                if ("00000" == dt.winddirectionandstrenght)
                {
                    Console.WriteLine("     no wind " + dt.locality+" "+dt.time);
                }
            }
            Console.WriteLine("  5. Task ");
            Console.WriteLine("     Localities taking part in measurements ");
            foreach (mystruct dt3 in tmb2)
            {
                Console.WriteLine("     Given loclity " + dt3.localitycode);
            }
        }
        }
    
       class Program
        {
            static void Main(string[] args)
            {
            reading display1 = new reading();
            display1.read_in();
            display1.count();
            display1.select();
            display1.measures();
            display1.displaying();
            //Console.WriteLine("Hello World!");
        }
        }
}
can I get help?
 
I can see places where you seem to by trying to sort the temperatures, but not where you are trying to sort the line numbers.

I don't understand why you need to sort the temperatures? To get the minimum and maximum values, you just need to scan through the array to find the minimum and max. You don't need to sort the array and then pick out the first and last elements. Besides sorting the temperatures also skews your data now because I would assume you want to keep the chronological ups and downs of the temperature. By sorting it, you will now have the temperatures going from lowest to highest and it doesn't reflect the chronological progression of the temperature over time.

I also don't understand why you would would need to sort by line number. What does that buy you?

I also don't understand why you have that pair of two dimensional arrays. They seem to be completely useless for your goal of presenting the data for each locality, and for the times within that locality. If you need to store tabular data, use a DataTable with properly name columns.
 
I can see places where you seem to by trying to sort the temperatures, but not where you are trying to sort the line numbers.

I don't understand why you need to sort the temperatures? To get the minimum and maximum values, you just need to scan through the array to find the minimum and max. You don't need to sort the array and then pick out the first and last elements. Besides sorting the temperatures also skews your data now because I would assume you want to keep the chronological ups and downs of the temperature. By sorting it, you will now have the temperatures going from lowest to highest and it doesn't reflect the chronological progression of the temperature over time.

I also don't understand why you would would need to sort by line number. What does that buy you?

I also don't understand why you have that pair of two dimensional arrays. They seem to be completely useless for your goal of presenting the data for each locality, and for the times within that locality. If you need to store tabular data, use a DataTable with properly name columns.
if I sort the temperartures I get the min and max values by line. with lenght and sum I can get the mean temperatures. every line means a city code.
 
Why not have a Min column and a Max column?
 
Why not have a Min column and a Max column?
theoretically I have but not not yet initialized. only the city code works yet but I would like the rest too, min max and average temperature.
this would be the mentioned part, looking difficult. can I get help? thank you,
detail:
      mystruct mydata1 = new mystruct();
                    mydata1.localitycode = tomb[i];
                    Console.WriteLine(" " + piece + " tomb[ " + i + " ] " + mydata1.localitycode);
                    mydata1.values[i, j] = Vektor[i, j];
                   /// mydata1.sumval = 0;
                   // mydata1.sumpiece =0;
                   //mydata1.meantempr =0;
                   // mydata1.mintempr =0;
                   // mydata1.maxtempr =0;

                    tmb2.Add(mydata1);
 
Last edited:
my new code is :
// if sort works first and last gives min and max values by temperature row
attemp2:
 Console.WriteLine(piece + " piece ");
            for (i = 0; i < piece; i++)
            {
                //Console.WriteLine(db + " tomb[ " + i + " ] " + tomb[i]);
                if (tomb[i] != "empty")
                {
                    mystruct mydata1 = new mystruct();
                 
                    mydata1.localitycode = tomb[i];
                    Console.WriteLine("  " + piece + " tomb[ " + i + " ] " + mydata1.localitycode);
                    mydata1.values[i, j].Sort(Vektor[i, j]);
                    mydata1.sumval = mydata1.values[i, j].Sum();
                    mydata1.sumpiece = mydata1.values[i, j].Count();
                    mydata1.meantempr = mydata1.sumval/ mydata1.sumpiece;
                   // mydata1.mintempr =0;
                   // mydata1.maxtempr =0;

                    tmb2.Add(mydata1);
                    if (list1[j].time.Substring(0, 2) == time[l].ToString() == true)
                    {
                        if (lista[j].homerseklet > 0)

                            // Console.Write(list1[j].time.Substring(0, 2) + " hour " + list1[j].temperature + " degree ");
                            Vektor[i, j] = list1[j].temperature;
                           // Vektor2[i, j].Sort(Vektor[i, j]);
                            lst1.Add(Vektor[i, j]);


                        }

                    }

                }
 
Hi
I post the whole code to present the entire code the find errors. I need help with it. I am beginner. the selection works the rest don'tthank you.
using System;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;

namespace metreport
{
//using System;
class mystruct
{
public string localitycode { get; set; }
public string[] measuredvalue { get; set; }
public int[,] values { get; set; }
public int sumval { get; set; }
public int sumpiece { get; set; }
public float meantempr { get; set; }
public int mintempr { get; set; }
public int maxtempr { get; set; }
}
class datas0
{
public string locality { get; set; }
public string time { get; set; }
public string winddirectionandstrenght { get; set; }
public int temperature { get; set; }
public int lineupnm { get; set; }

public int values { get; set; }
}

class reading
{
int piece = -1;
string time = ""; string lastmeasures = "";


int requirednm = 0;
int maxtempr = 0;
public int mintepr = 0;
int tempr = 0;
int maxindex = 0;
int lenght1 = 0;
string requiredlocality = "";
public List<datas0> list1 = new List<datas0>();
public List<int> temperaturelist = new List<int>();
public List<string> localities = new List<string>();
public List<string[]> appointmenttime = new List<string[]>(2);
public void read_in()
{

string read = @"c:\Users\Public\textfiles\tavirathu13.txt";
using (StreamReader sr = new StreamReader(read, Encoding.Default))
{
//StreamReader sr = new StreamReader(olvas, Encoding.Default);

//List<adatok> lista = new List<adatok>();

while (!sr.EndOfStream)
{
string[] row = sr.ReadLine().Split(' ');
//string[] elemek = sor.Split(' ');
datas0 data = new datas0();

data.locality = row[0];
data.time = row[1];
data.winddirectionandstrenght = row[2];
data.temperature = Int32.Parse(row[3]);
list1.Add(data);
piece++;
data.lineupnm = piece;
}
Random rd = new Random();
requirednm = rd.Next(1, piece);
lenght1 = piece;
}
}
public void count()
{
int n = -1;
foreach (datas0 dt in list1)
{ n++;
if (n == requirednm)
{

requiredlocality = dt.locality;
time = dt.time;

}


}
n = 0;
int m = 0;
foreach (datas0 dt in list1)
{
//m++;
//maxindex = m;
if (list1[requirednm].locality == dt.locality)
{
time = dt.time;
// Console.WriteLine(" m " + m + " telepules " + kerttelepules + " " + ido + " " + hom);
tempr = dt.temperature;
temperaturelist.Add(tempr);
temperaturelist.Sort();
}
lastmeasures = time;
}
//Console.WriteLine(" n " + n + " ido " + utolsomeres);


foreach (int ct in temperaturelist)
{
//Console.WriteLine(" homerseklet " +ct);
maxtempr = ct;
}
datas0 datas11 = new datas0();
//datas11.mintempr = temperaturelist[0];
//Console.WriteLine(" min homersekle " + minhom);
//maxhom = homersekletlista[maxindex-1];//
//Console.WriteLine(" max homersekle " + maxhom);
/*

/* */
}
//List<int> a = new List<int>();
int[] a2 = new int[900];
int i = 0;
int j = 0;
int k = -1;

string[] tomb = new string[900];
List<mystruct> tmb2 = new List<mystruct>();
List<int> lst1 = new List<int>();
List<int> lst2 = new List<int>();
int[,] Vektor = new int[80, 380];
int[,] Vektor2 = new int[80, 380];

// hossz = str1.Length;

public void select()
{
for (i = 0; i < lenght1; i++)
{
for (j = 0; j < lenght1; j++)
{
if (list1[j].locality == list1.locality)
{

a2[j] += 1;
if (a2[j] < 2)
{
//mystruct myrek = new mystruct();

//tomb = Convert.ToString(str1);
// myrek.kar = lista[j].telepules;

k = k + 1;
tomb = list1.locality;

}
else
{
tomb = "empty";
}

}
// Console.WriteLine(" " + tomb);
}
//Console.WriteLine(" tomb[ " + i + " ] " + tomb);
}
Console.WriteLine(piece + " piece ");
for (i = 0; i < piece; i++)
{
//Console.WriteLine(db + " tomb[ " + i + " ] " + tomb);
if (tomb != "empty")
{
mystruct mydata1 = new mystruct();

mydata1.localitycode = tomb;
Console.WriteLine(" " + piece + " tomb[ " + i + " ] " + mydata1.localitycode);
mydata1.values[i, j].Sort(Vektor[i, j]);
mydata1.sumval = mydata1.values[i, j].Sum();
mydata1.sumpiece = mydata1.values[i, j].Count();
mydata1.meantempr = mydata1.sumval/ mydata1.sumpiece;
// mydata1.mintempr =0;
// mydata1.maxtempr =0;

tmb2.Add(mydata1);
if (list1[j].time.Substring(0, 2) == ora[l].ToString() == true)
{
if (lista[j].homerseklet > 0)

// Console.Write(lista[j].ido.Substring(0, 2) + " ora " + lista[j].homerseklet + " fok ");
Vektor[i, j] = list1[j].temperature;
// Vektor2[i, j].Sort(Vektor[i, j]);
lst1.Add(Vektor[i, j]);


}

}

}
}


foreach (mystruct dt3 in tmb2)
{
Console.WriteLine(" tmb2[ ] " + dt3.localitycode);
}

}

int[] ora = new int[4] { 1, 7, 13, 19 };
int l = 0;
//List<int[,]> vektor = new List<int[,]>();

List<int> MNumbers = new List<int>();
int[] measurementList = new int[400];
List<Dictionary<string, int[]>> measurements = new List<Dictionary<string, int[]>>();

public void measures()
{
Console.WriteLine(" help needed for datastructure ");
Console.WriteLine(" 1 ");
Console.WriteLine(" tmb2 " + tmb2.Count);
Console.WriteLine(" 2 ");
for (int i3=0;i3< tmb2.Count; i3++)
{
Console.WriteLine(" ");
Console.WriteLine(" " + tmb2.Count + " tmb2[ "+ i3+ "] " + tmb2[i3].localitycode);
Console.WriteLine(" ");
for (j = 0; j < piece; j++)
{

if (tmb2[i3].localitycode == list1[j].locality)
{
// Console.Write(" " + lista[j].homerseklet);
for (l=0;l<4;l++)
{
/* */
if (list1[j].time.Substring(0, 2)==ora[l].ToString() == true)
{
if (list1[j].temperature > 0 )
{
mystruct rek1 = new mystruct();
List<datas0> mert1 = new List<datas0>();
// mystruct merthom = new mystruct();
//Console.Write(" j "+j+" "+lista[j].ido.Substring(0, 2) + " ora " + lista[j].homerseklet + " fok ");
Console.Write( " " + list1[j].temperature + " degree ");
Vektor[i3, j] = list1[j].temperature;
//values[j] = list1[j].temperature;
// measurementList[j]= Vektor[i3, j]);
// measurements[i3].Add(tmb2[j].localitycode, measurementList[j]);
Console.Write(" " + Vektor[i3, j] + " degree ");

lst1.Add(Vektor[i3, j]);
// rek1.values[j] = list1[j].temperature;
// mert1[].ertekek.Add(list1[j].homerseklet.ToString());


}
//Console.Write(" ");
}

}

}

}
//Console.WriteLine(" ");


}
Console.WriteLine(" ");
// foreach (int a1 in lst1)
// {
// Console.Write(" " + a1);

// }
/// lst1.Clear();
}
int i1 = 0;
int j1 = 0;
public void displaying()
{
/*
for (i1 = 0; i1 < 100; i1++)
{
for (j1 = 0; j1 < db; j1++)
{ if (Vektor[i1, j1] != 0)
{
//Array.Sort();
Console.Write(" v " + Vektor[i1, j1]);
}
}
Console.WriteLine(" ");
}
*/
for (int i = 0; i<piece; i++)
{
Console.WriteLine(" ");
// rekordlista adat = new rekordlista();

Console.WriteLine(
" Lineup number " + list1.lineupnm +
" LOcality " + list1.locality +
" Time " + list1.time +
" Wind dorection and strenght " + list1.winddirectionandstrenght +
" Temperature " + list1.temperature
);

//fordulo = fordulo + Int32.Parse(rlista.fordulo);
//telitalalatok = telitalalatok + Int32.Parse(rlista.Ndarab13p1talalat);
//osszeg = osszeg + rlista.ossznyeremeny;

}
Console.WriteLine(" Number of records " + piece);
Console.WriteLine(" 2. Task ");
Console.WriteLine(" Requested code " + requirednm + " Locality " + list1[requirednm].locality+ " Time " + list1[requirednm].time);
Console.WriteLine(" Required locality code " + requiredlocality);
Console.WriteLine(" Last measured data " + lastmeasures);
Console.WriteLine(" 3. Task ");
Console.WriteLine(" The measured temperature maximum "+maxtempr+ " Minimal temperature "+mintepr);
Console.WriteLine(" 4. Task ");
foreach (datas0 dt in list1 )
{
if ("00000" == dt.winddirectionandstrenght)
{
Console.WriteLine(" no wind " + dt.locality+" "+dt.time);
}
}
Console.WriteLine(" 5. Task ");
Console.WriteLine(" Localities taking part in measurements ");
foreach (mystruct dt3 in tmb2)
{
Console.WriteLine(" Given loclity " + dt3.localitycode);
}
}
}

class Program
{
static void Main(string[] args)
{
reading display1 = new reading();
display1.read_in();
display1.count();
display1.select();
display1.measures();
display1.displaying();
//Console.WriteLine("Hello World!");
}
}
}

mteo2:
using System;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;

namespace metreport
{
    //using System;
    class mystruct
    {
        public string localitycode { get; set; }
        public string[] measuredvalue { get; set; }
        public int[,] values { get; set; }
        public int sumval { get; set; }
        public int sumpiece { get; set; }
        public float meantempr { get; set; }
        public int mintempr { get; set; }
        public int maxtempr { get; set; }
    }
    class datas0
    {
        public string locality { get; set; }
        public string time { get; set; }
        public string winddirectionandstrenght { get; set; }
        public int temperature { get; set; }
        public int lineupnm { get; set; }
    
        public int values { get; set; }
   }

    class reading
    {
        int piece = -1;
        string time = ""; string lastmeasures = "";


        int requirednm = 0;
        int maxtempr = 0;
        public int mintepr = 0;
        int tempr = 0;
        int maxindex = 0;
        int lenght1 = 0;
        string requiredlocality = "";
        public List<datas0> list1 = new List<datas0>();
        public List<int> temperaturelist = new List<int>();
        public List<string> localities = new List<string>();
        public List<string[]> appointmenttime = new List<string[]>(2);
        public void read_in()
        {

            string read = @"c:\Users\Public\textfiles\tavirathu13.txt";
            using (StreamReader sr = new StreamReader(read, Encoding.Default))
            {
                //StreamReader sr = new StreamReader(olvas, Encoding.Default);

                //List<adatok> lista = new List<adatok>();

                while (!sr.EndOfStream)
                {
                    string[] row = sr.ReadLine().Split(' ');
                    //string[] elemek = sor.Split(' ');
                    datas0 data = new datas0();

                    data.locality = row[0];
                    data.time = row[1];
                    data.winddirectionandstrenght = row[2];
                    data.temperature = Int32.Parse(row[3]);
                    list1.Add(data);
                    piece++;
                    data.lineupnm = piece;
                }
                Random rd = new Random();
                requirednm = rd.Next(1, piece);
                lenght1 = piece;
            }
        }
        public void count()
        {
            int n = -1;
            foreach (datas0 dt in list1)
            { n++;
                if (n == requirednm)
                {

                    requiredlocality = dt.locality;
                    time = dt.time;

                }


            }
            n = 0;
            int m = 0;
            foreach (datas0 dt in list1)
            {
                //m++;
                //maxindex = m;
                if (list1[requirednm].locality == dt.locality)
                {
                    time = dt.time;
                    // Console.WriteLine(" m " + m + " telepules " + kerttelepules + "  " + ido + " " + hom);
                    tempr = dt.temperature;
                    temperaturelist.Add(tempr);
                    temperaturelist.Sort();
                }
                lastmeasures = time;
            }
            //Console.WriteLine(" n " + n + " ido " + utolsomeres);


            foreach (int ct in temperaturelist)
            {
                //Console.WriteLine(" homerseklet " +ct);
                maxtempr = ct;
            }
            datas0 datas11 = new datas0();
            //datas11.mintempr = temperaturelist[0];
            //Console.WriteLine(" min  homersekle   " + minhom);
            //maxhom = homersekletlista[maxindex-1];//
            //Console.WriteLine(" max  homersekle   " + maxhom);
            /*

             /*       */
        }
        //List<int> a = new List<int>();
        int[] a2 = new int[900];
        int i = 0;
        int j = 0;
        int k = -1;

        string[] tomb = new string[900];
        List<mystruct> tmb2 = new List<mystruct>();
        List<int> lst1 = new List<int>();
        List<int> lst2 = new List<int>();
        int[,] Vektor = new int[80, 380];
        int[,] Vektor2 = new int[80, 380];

        // hossz = str1.Length;

        public void select()
        {
            for (i = 0; i < lenght1; i++)
            {
                for (j = 0; j < lenght1; j++)
                {
                    if (list1[j].locality == list1[i].locality)
                    {

                        a2[j] += 1;
                        if (a2[j] < 2)
                        {
                            //mystruct myrek = new mystruct();

                            //tomb[i] = Convert.ToString(str1[i]);
                            // myrek.kar = lista[j].telepules;

                            k = k + 1;
                            tomb[i] = list1[i].locality;

                        }
                        else
                        {
                            tomb[i] = "empty";
                        }

                    }
                    // Console.WriteLine(" " + tomb[i]);
                }
                //Console.WriteLine(" tomb[ " + i + " ] " + tomb[i]);
            }
            Console.WriteLine(piece + " piece ");
            for (i = 0; i < piece; i++)
            {
                //Console.WriteLine(db + " tomb[ " + i + " ] " + tomb[i]);
                if (tomb[i] != "empty")
                {
                    mystruct mydata1 = new mystruct();
                  
                    mydata1.localitycode = tomb[i];
                    Console.WriteLine(" " + piece + " tomb[ " + i + " ] " + mydata1.localitycode);
                    mydata1.values[i, j].Sort(Vektor[i, j]);
                    mydata1.sumval = mydata1.values[i, j].Sum();
                    mydata1.sumpiece = mydata1.values[i, j].Count();
                    mydata1.meantempr = mydata1.sumval/ mydata1.sumpiece;
                   // mydata1.mintempr =0;
                   // mydata1.maxtempr =0;

                    tmb2.Add(mydata1);
                    if (list1[j].time.Substring(0, 2) == ora[l].ToString() == true)
                    {
                        if (lista[j].homerseklet > 0)

                            // Console.Write(lista[j].ido.Substring(0, 2) + " ora " + lista[j].homerseklet + " fok ");
                            Vektor[i, j] = list1[j].temperature;
                           // Vektor2[i, j].Sort(Vektor[i, j]);
                            lst1.Add(Vektor[i, j]);


                        }

                    }

                }
            }


            foreach (mystruct dt3 in tmb2)
            {
                Console.WriteLine(" tmb2[ ] " + dt3.localitycode);
            }

        }

        int[] ora = new int[4] { 1, 7, 13, 19 };
        int l = 0;
        //List<int[,]> vektor = new List<int[,]>();

        List<int> MNumbers = new List<int>();
        int[] measurementList = new int[400];
        List<Dictionary<string, int[]>> measurements = new List<Dictionary<string, int[]>>();

        public void measures()
        {
            Console.WriteLine(" help needed for datastructure ");
            Console.WriteLine(" 1 ");
            Console.WriteLine(" tmb2 " + tmb2.Count);
            Console.WriteLine(" 2 ");
            for (int i3=0;i3< tmb2.Count; i3++)
                {
                Console.WriteLine("  ");
                Console.WriteLine("  " + tmb2.Count + " tmb2[ "+ i3+ "] " + tmb2[i3].localitycode);
                Console.WriteLine("  ");
                for (j = 0; j < piece; j++)
                    {
                    
                        if (tmb2[i3].localitycode == list1[j].locality)
                        {
                           // Console.Write(" " + lista[j].homerseklet);
                        for (l=0;l<4;l++)
                        {
                        /* */   
                            if (list1[j].time.Substring(0, 2)==ora[l].ToString() == true)
                            {
                                if (list1[j].temperature > 0 )
                                {
                                   mystruct rek1 = new mystruct();
                                    List<datas0> mert1 = new List<datas0>();
                               // mystruct merthom = new mystruct();
                                    //Console.Write(" j "+j+" "+lista[j].ido.Substring(0, 2) + " ora " + lista[j].homerseklet + " fok ");
                                    Console.Write( "  " + list1[j].temperature + " degree ");
                                    Vektor[i3, j] = list1[j].temperature;
                                    //values[j] = list1[j].temperature;
                                    // measurementList[j]= Vektor[i3, j]);
                                    // measurements[i3].Add(tmb2[j].localitycode, measurementList[j]);
                                    Console.Write("  " + Vektor[i3, j] + " degree ");

                                    lst1.Add(Vektor[i3, j]);
                                   // rek1.values[j] = list1[j].temperature;
                                   // mert1[].ertekek.Add(list1[j].homerseklet.ToString());


                                }
                                //Console.Write("  ");
                            }
                                                      
                        }
                        
                        }
                  
                    }
                //Console.WriteLine(" ");
                

            }
            Console.WriteLine(" ");
           // foreach (int a1 in lst1)
           // {
               // Console.Write("   " + a1);

          //  }
          ///  lst1.Clear();
        }
        int i1 = 0;
        int j1 = 0;
        public void displaying()
        {
            /*
            for (i1 = 0; i1 < 100; i1++)
            {
                for (j1 = 0; j1 < db; j1++)
                    { if (Vektor[i1, j1] != 0)
                        {
                            //Array.Sort();
                            Console.Write(" v " + Vektor[i1, j1]);
                        }
                     }
                Console.WriteLine("  ");
            }
            */
            for (int i = 0; i<piece; i++)
                {
                    Console.WriteLine(" ");
                // rekordlista adat = new rekordlista();
              
                Console.WriteLine(
                         " Lineup number   " + list1[i].lineupnm +
                         " LOcality " + list1[i].locality +
                         " Time   " + list1[i].time +
                         " Wind dorection and strenght " + list1[i].winddirectionandstrenght +
                         " Temperature " + list1[i].temperature
                        );

                    //fordulo = fordulo + Int32.Parse(rlista[i].fordulo);
                    //telitalalatok = telitalalatok + Int32.Parse(rlista[i].Ndarab13p1talalat);
                    //osszeg = osszeg + rlista[i].ossznyeremeny;

                }
            Console.WriteLine(" Number of records " + piece);
            Console.WriteLine("  2. Task ");
            Console.WriteLine("      Requested code " + requirednm + " Locality " + list1[requirednm].locality+ " Time   " + list1[requirednm].time);
            Console.WriteLine("      Required locality code " + requiredlocality);
            Console.WriteLine("      Last measured data   " + lastmeasures);
            Console.WriteLine("  3. Task ");
            Console.WriteLine("      The measured temperature maximum "+maxtempr+ " Minimal temperature "+mintepr);
            Console.WriteLine("  4. Task ");
            foreach (datas0 dt in list1 )
            {
                if ("00000" == dt.winddirectionandstrenght)
                {
                    Console.WriteLine("     no wind " + dt.locality+" "+dt.time);
                }
            }
            Console.WriteLine("  5. Task ");
            Console.WriteLine("     Localities taking part in measurements ");
            foreach (mystruct dt3 in tmb2)
            {
                Console.WriteLine("     Given loclity " + dt3.localitycode);
            }
        }
        }
    
       class Program
        {
            static void Main(string[] args)
            {
            reading display1 = new reading();
            display1.read_in();
            display1.count();
            display1.select();
            display1.measures();
            display1.displaying();
            //Console.WriteLine("Hello World!");
        }
        }
}
 
Last edited:
You should never have to post that much code. Part of the problem is that you have done a whole bunch of stuff and you don't have a clue what works and what doesn't. This is exactly why you need to break things down into smaller parts and tackle one part at a time. Do one thing and get it working, then do another thing. If something breaks, you know exactly where the issue must be because it must be in the part that you have changed since it was last working. The smaller your units of work, the smaller that area of change will be and the easier it is to track down the issue. Having to wade through all that code in the hope of finding something that doesn't work is just crazy and, while I can't speak for others, it is something that I won't be doing.

You should stop what you're doing and engage in a bit of planning and design. It can be hard when you're a beginner but it's something that you need to learn so no better time than right now. Break up your work into the smallest units you can and work on one at a time. Each unit you work on doesn't have to be related to the one you worked on previously either. You can work on two completely separate things and then merge them together with a third later. When you do it like that, you can come to us as soon as you encounter the first issue and you can show us the minimum amount of code required to demonstrate the issue. If that means creating a new test project to isolate that functionality then that's what you do. What you don't do is dump a huge wad of code on us where the vast majority is irrelevant. That's called software development and it's different to code-writing.
 

Latest posts

Back
Top Bottom