{"id":384,"date":"2026-05-29T08:55:27","date_gmt":"2026-05-29T08:55:27","guid":{"rendered":"https:\/\/informatika.tbg.hu\/?page_id=384"},"modified":"2026-05-29T08:55:27","modified_gmt":"2026-05-29T08:55:27","slug":"bejaros-ciklus-foreach","status":"publish","type":"page","link":"https:\/\/informatika.tbg.hu\/index.php\/bejaros-ciklus-foreach\/","title":{"rendered":"bej\u00e1r\u00f3s ciklus (foreach)"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">A foreach ciklust akkor haszn\u00e1ljuk, ha egy gy\u0171jtem\u00e9ny (t\u00f6mb, lista, halmaz, &#8230;) minden elem\u00e9re szeretn\u00e9nk valamit v\u00e9grehajtani.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u00dagy k\u00e9pzeld el, mintha egy tan\u00e1r az eg\u00e9sz csoportot feleltetni akarja, \u00e9s egyes\u00e9vel mindenkit kih\u00edv:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">-Gyere ki a t\u00e1bl\u00e1hoz <em>fiam<\/em>!<br>-Mit tudsz a ciklusokr\u00f3l? Mondjad <em>fiam<\/em>!<br>&#8230;. <br>J\u00f6het a k\u00f6vetkez\u0151!<br>-Gyere ki a t\u00e1bl\u00e1hoz <em>fiam<\/em>!<br>-Mit tudsz a ciklusokr\u00f3l? Mondjad <em>fiam<\/em>!<br>&#8230;. <br>J\u00f6het a k\u00f6vetkez\u0151! &#8230;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Figyeld meg, hogy a tan\u00e1r nem bajl\u00f3dik a nevekkel, nem \u00e9rdekli, hogy ki hanyadik, elnevezi \u0151ket <em>fiam<\/em>nak, \u00e9s \u00fagy kommunik\u00e1l.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Ez akkor mondatszer\u0171 le\u00edr\u00e1ssal:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>foreach (adatt\u00edpus megnevez\u00e9s in gy\u0171jtem\u00e9ny)\n{\n   ciklusmag;\n}<\/code><\/pre>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"alignright size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"30\" height=\"203\" src=\"https:\/\/informatika.tbg.hu\/wp-content\/uploads\/2026\/05\/foreach.png\" alt=\"\" class=\"wp-image-385\"\/><\/figure>\n<\/div>\n\n\n<p class=\"wp-block-paragraph\">Feladat: Adott egy sz\u00e1mok nev\u0171 lista, mely sz\u00e1mokat tartalmaz. \u00cdrassuk ki a lista elemeit egym\u00e1s al\u00e1!<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>List&lt;int> sz\u00e1mok = new List&lt;int>() { 5, 4, 3, 5, 4, 2, 5, 5, 1, 5 };\nforeach (int elem in sz\u00e1mok)\n{\n    Console.WriteLine(elem);\n}\n\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Megjegyz\u00e9s : A GUI felaj\u00e1nlja a var kulcssz\u00f3t a ciklus aktu\u00e1lis elem\u00e9nek adatt\u00edpus\u00e1ra. Ilyenkor a ford\u00edt\u00f3 fogja meghat\u00e1rozni (kital\u00e1lni) az adatt\u00edpust a gy\u0171jtem\u00e9ny alapj\u00e1n. Ha egy\u00e9rtelm\u0171, haszn\u00e1ld nyugodtan.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>A foreach ciklust akkor haszn\u00e1ljuk, ha egy gy\u0171jtem\u00e9ny (t\u00f6mb, lista, halmaz, &#8230;) minden elem\u00e9re szeretn\u00e9nk valamit v\u00e9grehajtani. \u00dagy k\u00e9pzeld el, mintha egy tan\u00e1r az eg\u00e9sz csoportot feleltetni akarja, \u00e9s egyes\u00e9vel mindenkit kih\u00edv: -Gyere ki a t\u00e1bl\u00e1hoz fiam!-Mit tudsz a ciklusokr\u00f3l? Mondjad fiam!&#8230;. J\u00f6het a k\u00f6vetkez\u0151!-Gyere ki a t\u00e1bl\u00e1hoz fiam!-Mit tudsz a ciklusokr\u00f3l? Mondjad fiam!&#8230;. J\u00f6het [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-384","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/informatika.tbg.hu\/index.php\/wp-json\/wp\/v2\/pages\/384","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/informatika.tbg.hu\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/informatika.tbg.hu\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/informatika.tbg.hu\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/informatika.tbg.hu\/index.php\/wp-json\/wp\/v2\/comments?post=384"}],"version-history":[{"count":1,"href":"https:\/\/informatika.tbg.hu\/index.php\/wp-json\/wp\/v2\/pages\/384\/revisions"}],"predecessor-version":[{"id":386,"href":"https:\/\/informatika.tbg.hu\/index.php\/wp-json\/wp\/v2\/pages\/384\/revisions\/386"}],"wp:attachment":[{"href":"https:\/\/informatika.tbg.hu\/index.php\/wp-json\/wp\/v2\/media?parent=384"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}