From 2ff921eb03ef77d69cfbf6110201aebad3f6973a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kov=C3=A1cs=20Rudolf?= Date: Mon, 12 Oct 2026 13:08:38 +0200 Subject: [PATCH] =?UTF-8?q?List=C3=A1k=20haszn=C3=A1lata?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Listak/Listak.sln | 25 +++++++++++++ Listak/Listak/Listak.csproj | 10 +++++ Listak/Listak/Program.cs | 73 +++++++++++++++++++++++++++++++++++++ 3 files changed, 108 insertions(+) create mode 100644 Listak/Listak.sln create mode 100644 Listak/Listak/Listak.csproj create mode 100644 Listak/Listak/Program.cs diff --git a/Listak/Listak.sln b/Listak/Listak.sln new file mode 100644 index 0000000..7674518 --- /dev/null +++ b/Listak/Listak.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.11.35222.181 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Listak", "Listak\Listak.csproj", "{765CF942-185F-4804-8D73-9F53210946CD}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {765CF942-185F-4804-8D73-9F53210946CD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {765CF942-185F-4804-8D73-9F53210946CD}.Debug|Any CPU.Build.0 = Debug|Any CPU + {765CF942-185F-4804-8D73-9F53210946CD}.Release|Any CPU.ActiveCfg = Release|Any CPU + {765CF942-185F-4804-8D73-9F53210946CD}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {E18CA4B6-0528-45BE-970F-4227CD936C76} + EndGlobalSection +EndGlobal diff --git a/Listak/Listak/Listak.csproj b/Listak/Listak/Listak.csproj new file mode 100644 index 0000000..2150e37 --- /dev/null +++ b/Listak/Listak/Listak.csproj @@ -0,0 +1,10 @@ + + + + Exe + net8.0 + enable + enable + + + diff --git a/Listak/Listak/Program.cs b/Listak/Listak/Program.cs new file mode 100644 index 0000000..37bf728 --- /dev/null +++ b/Listak/Listak/Program.cs @@ -0,0 +1,73 @@ +namespace Listak +{ + internal class Program + { + static void Main(string[] args) + { + List szamok=new List(); + List szamok2 = new List(); + + Console.WriteLine($"Elemszám:{szamok.Count}"); + szamok.Add(123); + szamok.Add(56); + szamok.Add(-129); + + Console.WriteLine($"Elemszám:{szamok.Count}"); + + Console.WriteLine($"Indexelhető:{szamok[1]}"); + + //Törlés érték szerint + szamok.Remove(-129); + + //Törlés index szerint + szamok.RemoveAt(1); + szamok2.Add(33); + szamok2.Add(79); + szamok2.Add(122); + + szamok.AddRange(szamok2); + + Console.WriteLine($"Elemszám:{szamok.Count}"); + + for (int i = 0; i < szamok.Count; i++) + { + Console.Write(szamok[i]+" "); + } + Console.WriteLine(); + + foreach (var i in szamok) + { + Console.Write(i+" "); + } + Console.WriteLine(); + + Console.WriteLine($"Összeg:{szamok.Sum()},Átlag:{szamok.Average()},Min:{szamok.Min()},Max:{szamok.Max()}"); + + Random random = new Random(); + + for (int i = 0; i < 200; i++) + { + szamok.Add(random.Next(-100, 100)); + } + + //Gyűjtsük ki egy külön listába a pozitív számokat! + + var pozitivak = szamok.FindAll(x=>x>=0); + + foreach (var i in pozitivak) + { + Console.WriteLine(i); + } + + //Szerepel-e a listában 18? + + if (szamok.Any(x=>x>=18 && x<=30)) + { + Console.WriteLine("Van ilyen érték!"); + } else + { + Console.WriteLine("Nincs ilyen érték!"); + } + } + } +}