cfrank2000
Well-known member
- Joined
- Mar 6, 2021
- Messages
- 71
- Programming Experience
- Beginner
I have a string and I would like to compare its content with a string from a record list and I get the following error:
Severity Code Description Project File Line Suppression State
Error CS0019 Operator '==' cannot be applied to operands of type 'ArrayList' and 'string' toto C:\Users\Dell\source\repos\toto\toto\Program.cs 130 Active
Severity Code Description Project File Line Suppression State
Error CS0019 Operator '==' cannot be applied to operands of type 'ArrayList' and 'string' toto C:\Users\Dell\source\repos\toto\toto\Program.cs 130 Active
string comparison against record list string:
using System;
using System.IO;
using System.Text;
using System.Collections;
using System.Collections.Generic;
namespace toto
{
class Rekord
{
public string ev { get; set; }
public string het { get; set; }
public string fordulo { get; set; }
public string Ndarab13p1talalat { get; set; }
public string egydbtelitalalat { get; set; }
public string eredmenyek { get; set; }
public long ossznyeremeny { get; set; }
}
class beolvasas
{
static int db = 0;
static int telitalalatok = 0;
static int fordulo = 0;
static int egyfrd = 0;
public List<Rekord> rlista = new List<Rekord>();
public ArrayList minmax = new ArrayList();
public void beolvas()
{
string olvas = @"c:\Users\Public\textfiles\toto.txt";
using (StreamReader sr = new StreamReader(olvas, Encoding.Default))
{
string ev;
string het;
string egydbtelitalalat;
sr.ReadLine();
while (!sr.EndOfStream)
{
string[] sor = sr.ReadLine().Split(';');
Rekord adat = new Rekord();
adat.ev = sor[0];
adat.het = sor[1];
adat.fordulo = sor[2];
adat.Ndarab13p1talalat = sor[3];
adat.egydbtelitalalat = sor[4];
adat.eredmenyek = sor[5];
adat.ossznyeremeny = Int32.Parse(adat.Ndarab13p1talalat)*Int32.Parse(adat.egydbtelitalalat);
if (Int32.Parse(adat.fordulo) == 1)
{
egyfrd = egyfrd + 1;
// Console.WriteLine(" 1 Fordulo " + adat.fordulo);
minmax.Add(Int32.Parse(adat.egydbtelitalalat));
}
rlista.Add(adat);
db++;
}
Console.WriteLine(" 1 Fordulo " + egyfrd);
Console.WriteLine(db);
//Random rd = new Random();
//int rand_num = rd.Next(1, db);
}
}
public void kiir()
{
//int csere = 0;
long osszeg = 0;
double atlag = 0;
for (int i= 0; i<db;i++)
{
Console.WriteLine(" ");
// rekordlista adat = new rekordlista();
Console.WriteLine(
" Ev " + rlista[i].ev +
" Het " + rlista[i].het +
" Fordulo " + rlista[i].fordulo +
" N darab 13 + 1 " + rlista[i].Ndarab13p1talalat +
" Egy db telitalalat/osszeg " + rlista[i].egydbtelitalalat +
" Eredmeny " + rlista[i].eredmenyek);
fordulo = fordulo + Int32.Parse(rlista[i].fordulo);
telitalalatok = telitalalatok + Int32.Parse(rlista[i].Ndarab13p1talalat);
osszeg = osszeg + rlista[i].ossznyeremeny;
}
atlag = osszeg / db;
Console.WriteLine();
Console.WriteLine(
" 3 Feledat: Fordulo szama " + fordulo);
Console.WriteLine(
" 4 Feledat: 13 + 1-es \n talalatok szama " + telitalalatok);
Console.WriteLine(
" 5 Feledat: Atlag nyeremeny " + atlag);
int index = 0;
minmax.Sort();
int utolso = 0;
int indexmin = 0;
int a = 0;
foreach (int n in minmax)
{
index++;
//Console.WriteLine(" minmax " + n+" indexmin "+ indexmin + " index " + index);
if (n > 0)
{
a++;
if (a < 2)
{
indexmin = index;
}
}
utolso = n;
}
Console.WriteLine(" 6 Feledat: max. nyeremeny " + utolso + " index " + index);
Console.WriteLine(" 7 Feledat: min. nyeremeny " + minmax[indexmin-1] + " indexmin " + indexmin);
Console.WriteLine(" minmaxst " + minmax);
string minmaxst = " ";
minmaxst = Convert.ToString(minmax);
for (int i = 0; i < db; i++)
{
//ev = rlista[i].ev;
minmaxst = rlista[i].egydbtelitalalat;
if (minmax == minmaxst)
{
Console.WriteLine(" minmaxst " + minmaxst);
}
Console.WriteLine(" osszeg " + rlista[i].egydbtelitalalat);
}
/*
for (int i = 0;i < minmax.Count; i++)
{
for (int j = 1; j < minmax.Count; j++)
{
if(minmax[i] < minmax[j - 1])
{
csere = minmax[i];
}
}
Console.WriteLine(
" minmax " + minmax[i]);
}*/
}
}
class Program
{
static void Main(string[] args)
{
beolvasas kiir1 = new beolvasas();
kiir1.beolvas();
kiir1.kiir();
Console.WriteLine("Hello World!");
}
}
}