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!");
        }
        }
}
 

cfrank2000

Well-known member
Joined
Mar 6, 2021
Messages
71
Programming Experience
Beginner
If I comment out the faulty part , it works , selects the city codes and under selected city codes the required temperatures. I need this temp. data in a data structure to get the mean value and max and min value, thank you.
 

Skydiver

Staff member
Joined
Apr 6, 2019
Messages
3,762
Location
Chesapeake, VA
Programming Experience
10+
Since this is an English language forum, it's very hard for us to understand your code where your identifiers are all in Hungarian. Can you put in a new post -- do not edit your original post -- with comments that translate some of the class member names, method names, and variables names so that we'll have half a chance of understanding your code?
 

cfrank2000

Well-known member
Joined
Mar 6, 2021
Messages
71
Programming Experience
Beginner
Since this is an English language forum, it's very hard for us to understand your code where your identifiers are all in Hungarian. Can you put in a new post -- do not edit your original post -- with comments that translate some of the class member names, method names, and variables names so that we'll have half a chance of understanding your code?
thank you, I'll do it.
 

cfrank2000

Well-known member
Joined
Mar 6, 2021
Messages
71
Programming Experience
Beginner
conform advice I converted Hungarian to English for making easier the help. I commented out the faulty part but signalized where I need help, thank you.
metreport:
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 string[] values { 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];

        // 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;
                            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[,]>();
      

        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].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;
                                    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 + " Telepules " + list1[requirednm].locality+ " Ido   " + 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+ " Minimum homerseklet "+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!");
        }
        }
}
 

jmcilhinney

C# Forum Moderator
Staff member
Joined
Apr 23, 2011
Messages
4,130
Location
Sydney, Australia
Programming Experience
10+
Help with what exactly? There's a lot of code there and I'm guessing that most of it is irrelevant. Please explain exactly what you're trying to achieve, how you're trying to achieve it and what happens when you try.
 

JohnH

C# Forum Moderator
Staff member
Joined
Apr 23, 2011
Messages
1,222
Location
Norway
Programming Experience
10+
merged threads
 

cfrank2000

Well-known member
Joined
Mar 6, 2021
Messages
71
Programming Experience
Beginner
Hi
thank you for answer. I tried internet but no luck.
thank you for answer. I try to achieve the following: running the program we can se up after locality codes help needed for data structure, I need to place al locality code related temperature measurements in some sort of ' embedded list ' to get min and max temperature for a city code plus mean temperature. by the way min temperature is not working giving 0 all the time, thank you.
update
metreport1:
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 string[] values { 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];

        // 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;
                            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[,]>();
     

        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].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;
                                    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!");
        }
        }
}
 

cfrank2000

Well-known member
Joined
Mar 6, 2021
Messages
71
Programming Experience
Beginner
I checked the net for solution but no luck. possibly I would need a list where list components are also lists. the problem is I tried foreach and for loop but it was wrong , useless because I don't know how to do it. the reason for this strange data is to use sort function for min and max values and count temperature mean values by city code. please help me with solution, thank you.
 

Skydiver

Staff member
Joined
Apr 6, 2019
Messages
3,762
Location
Chesapeake, VA
Programming Experience
10+
You don't need to sort to find the minimum or maximum values from a list. You certainly don't need to sort to count the number of items in a list.

Your instincts are correct that you'll likely need lists. The data structure that you are seeking, though is called a dictionary. Let me get you started with some pseudo code (assuming using C# 9.0):
C#:
record Measurement
{
    public string Locality { get; init; }
    public string Time { get; init; }
    public string WindDirectionAndStrength { get; init; }
    public int Temperature { get; init; }
    public int LineNumber { get; init; }
}

:

var localityMeasurements = new Dictionary<string, List<Measurement>>();

int lineNumeber = 1;
foreach(var line in File.ReadLines(inputFile))
{
    var columns = line.Split(' ');
    var locality = columns[0];
    var measurement = new Measurement
        {
            Locality = columns[0],
            Time = columns[1],
            WindDirectionAndStrength = columns[2],
            Temperature = int.Parse(columns[3]),
            LineNumber = lineNumber;
        };
    if (!localityMeasurements.ContainsKey(locality))
        localityMeasurements.Add(locality, new List<Measurement>());
    localityMeasurements[locality].Add(measurement);
    lineNumber++;
}

foreach(var kvp in localityMeasurements)
{
    var locality = kvp.Key;
    var measurements = kvp.Value;
    var min = measurements.Min(m => m.Temperature);
    var max = measurements.Max(m => m.Temperature);
    var ave = measurements.Average(m => m.Temperature);
    Console.Writeline($"Locality: {locality}    Mininum:{min}    Maximum:{max}    Average:{ave}    Count:{measurements.Count}");
}
 

cfrank2000

Well-known member
Joined
Mar 6, 2021
Messages
71
Programming Experience
Beginner
You don't need to sort to find the minimum or maximum values from a list. You certainly don't need to sort to count the number of items in a list.

Your instincts are correct that you'll likely need lists. The data structure that you are seeking, though is called a dictionary. Let me get you started with some pseudo code (assuming using C# 9.0):
C#:
record Measurement
{
    public string Locality { get; init; }
    public string Time { get; init; }
    public string WindDirectionAndStrength { get; init; }
    public int Temperature { get; init; }
    public int LineNumber { get; init; }
}

:

var localityMeasurements = new Dictionary<string, List<Measurement>>();

int lineNumeber = 1;
foreach(var line in File.ReadLines(inputFile))
{
    var columns = line.Split(' ');
    var locality = columns[0];
    var measurement = new Measurement
        {
            Locality = columns[0],
            Time = columns[1],
            WindDirectionAndStrength = columns[2],
            Temperature = int.Parse(columns[3]),
            LineNumber = lineNumber;
        };
    if (!localityMeasurements.ContainsKey(locality))
        localityMeasurements.Add(locality, new List<Measurement>());
    localityMeasurements[locality].Add(measurement);
    lineNumber++;
}

foreach(var kvp in localityMeasurements)
{
    var locality = kvp.Key;
    var measurements = kvp.Value;
    var min = measurements.Min(m => m.Temperature);
    var max = measurements.Max(m => m.Temperature);
    var ave = measurements.Average(m => m.Temperature);
    Console.Writeline($"Locality: {locality}    Mininum:{min}    Maximum:{max}    Average:{ave}    Count:{measurements.Count}");
}
thank you for help
 

cfrank2000

Well-known member
Joined
Mar 6, 2021
Messages
71
Programming Experience
Beginner
Hi
i am sorry for coming again. I tried another way something might be closer to my knowledge level but I am facing conversion problem. I just try to place displayed data in data structure.

metreport2:
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 string[] values { 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];

        // 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;
                            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>();
        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;
                                    measurements[i3].Add(tmb2[i3].localitycode, Vektor[i3, 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:

Skydiver

Staff member
Joined
Apr 6, 2019
Messages
3,762
Location
Chesapeake, VA
Programming Experience
10+

Skydiver

Staff member
Joined
Apr 6, 2019
Messages
3,762
Location
Chesapeake, VA
Programming Experience
10+
I just try to place displayed data in data structure.
Why are trying to stick the displayed data into a data structure? You should be reading values out of your data structure and displaying them on screen.
 

cfrank2000

Well-known member
Joined
Mar 6, 2021
Messages
71
Programming Experience
Beginner
Why are trying to stick the displayed data into a data structure? You should be reading values out of your data structure and displaying them on screen.
thank you for answer. my reason for read data in a data structure to read out it in a created txt file named by city code. thank you.
 

cfrank2000

Well-known member
Joined
Mar 6, 2021
Messages
71
Programming Experience
Beginner
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:

Skydiver

Staff member
Joined
Apr 6, 2019
Messages
3,762
Location
Chesapeake, VA
Programming Experience
10+
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?
 

cfrank2000

Well-known member
Joined
Mar 6, 2021
Messages
71
Programming Experience
Beginner
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:

Skydiver

Staff member
Joined
Apr 6, 2019
Messages
3,762
Location
Chesapeake, VA
Programming Experience
10+
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?
 

cfrank2000

Well-known member
Joined
Mar 6, 2021
Messages
71
Programming Experience
Beginner
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.
 
Top Bottom