[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"detail-sidebar-cat-0-en-105":3,"doc-seo-685658-105":59,"doc-detail-685658-en":130,"doc-similar-685658":149},{"code":4,"msg":5,"data":6},0,"success",[7,13,18,23,28,33,38,43,48,51,55],{"id":8,"doc_module":4,"doc_module_name":9,"category_name":10,"show_sort_weight":11,"slug":12},1,"Document","Story & Novel",90,"story-novel",{"id":14,"doc_module":4,"doc_module_name":9,"category_name":15,"show_sort_weight":16,"slug":17},2,"Literature",80,"literature",{"id":19,"doc_module":4,"doc_module_name":9,"category_name":20,"show_sort_weight":21,"slug":22},4,"Exam",70,"exam",{"id":24,"doc_module":4,"doc_module_name":9,"category_name":25,"show_sort_weight":26,"slug":27},5,"Comic",60,"comic",{"id":29,"doc_module":4,"doc_module_name":9,"category_name":30,"show_sort_weight":31,"slug":32},6,"Technology",50,"technology",{"id":34,"doc_module":4,"doc_module_name":9,"category_name":35,"show_sort_weight":36,"slug":37},7,"Healthcare",40,"healthcare",{"id":39,"doc_module":4,"doc_module_name":9,"category_name":40,"show_sort_weight":41,"slug":42},8,"Research & Report",30,"research-report",{"id":44,"doc_module":4,"doc_module_name":9,"category_name":45,"show_sort_weight":46,"slug":47},9,"Religion & Spirituality",20,"religion-spirituality",{"id":46,"doc_module":4,"doc_module_name":9,"category_name":49,"show_sort_weight":46,"slug":50},"World Cup","world-cup",{"id":52,"doc_module":4,"doc_module_name":9,"category_name":53,"show_sort_weight":52,"slug":54},10,"Lifestyle","lifestyle",{"id":56,"doc_module":4,"doc_module_name":9,"category_name":57,"show_sort_weight":24,"slug":58},19,"General","general",{"code":4,"msg":60,"data":61},"ok",{"site_id":62,"language":63,"slug":64,"title":65,"keywords":66,"description":67,"schema_data":68,"social_meta":123,"head_meta":125,"extra_data":127,"updated_unix":129},105,"en","lesson-4-collections-and-iterators","Lesson 4 - Collections and iterators","","Lesson 4 explains key C# collection classes used to group objects and perform operations on them. It compares List\u003CT> and ArrayList, shows how to create collections, add items, access elements by index, and modify values. The lesson covers foreach iteration, removing items, inserting at specific positions, sorting with Sort(), and searching with Contains(), IndexOf(), and LastIndexOf(). It also introduces Capacity vs Count and using TrimExcess, then introduces iterators via enumerators.",{"@graph":69,"@context":122},[70,84,105],{"@type":71,"itemListElement":72},"BreadcrumbList",[73,77,79,82],{"item":74,"name":75,"@type":76,"position":8},"https://docshare.wps.com","Home","ListItem",{"item":78,"name":9,"@type":76,"position":14},"https://docshare.wps.com/document/",{"item":80,"name":30,"@type":76,"position":81},"https://docshare.wps.com/document/technology/",3,{"item":83,"name":65,"@type":76,"position":19},"https://docshare.wps.com/document/lesson-4-collections-and-iterators/685658/",{"url":83,"name":65,"@type":85,"image":86,"author":91,"headline":65,"publisher":94,"fileFormat":97,"inLanguage":63,"description":67,"dateModified":98,"datePublished":99,"encodingFormat":97,"isAccessibleForFree":100,"interactionStatistic":101},"DigitalDocument",{"url":87,"@type":88,"width":89,"height":90},"https://docshare.wps.com/thumbnails/lesson-4-collections-and-iterators/685658.png","ImageObject",300,407,{"name":92,"@type":93},"EvelynWrites","Person",{"url":74,"name":95,"@type":96},"DocShare","Organization","application/pdf","2026-11-12","2026-11-07",true,{"@type":102,"interactionType":103,"userInteractionCount":19},"InteractionCounter",{"@type":104},"ViewAction",{"@type":106,"mainEntity":107},"FAQPage",[108,114,118],{"name":109,"@type":110,"acceptedAnswer":111},"What are the main differences between List\u003CT> and ArrayList in this lesson?","Question",{"text":112,"@type":113},"List\u003CT> is in the System.Collections.Generic namespace, while ArrayList is in System.Collections. They both support similar operations to arrays and can grow or shrink as the stored item count changes.","Answer",{"name":115,"@type":110,"acceptedAnswer":116},"How do you access and change items in a C# list by index?",{"text":117,"@type":113},"Items are accessed using square brackets after the list name, where the first item is index 0. To change a value, use the index with the assignment operator, e.g., colorList[2] = \"Indigo\".",{"name":119,"@type":110,"acceptedAnswer":120},"How do IndexOf() and LastIndexOf() help when searching lists?",{"text":121,"@type":113},"IndexOf() returns the index of the first matching item, or -1 if the item is not found. LastIndexOf() returns the index of the last matching item, which is useful when duplicates exist.","https://schema.org",{"og:url":83,"og:type":124,"og:title":65,"og:site_name":95,"og:description":67},"article",{"robots":126,"canonical":83},"index,follow",{"doc_id":128,"site_id":62},685658,1794016351,{"code":4,"msg":5,"data":131},{"doc_id":128,"user_id":132,"nickname":92,"user_avatar":133,"doc_module":4,"category_id":29,"category_name":30,"doc_title":65,"doc_description":67,"doc_content":134,"file_id":135,"file_url":136,"file_type":137,"file_size":138,"view_count":19,"is_deleted":4,"is_public":8,"is_downloadable":8,"audit_status":8,"page_count":52,"language":139,"language_code":63,"site_id":62,"html_lang":63,"table_of_contents":140,"faqs":141,"seo_title":142,"seo_description":67,"update_tm":129,"read_time":143,"preview_page_count":8,"preview_urls":144},687212989558,"https://ap-avatar.wpscdn.com/davatar_a8503ba1806abce46bf441b54a3ca4cd","Programming in .NET  \nMicrosoft Development Center Serbia programming course  \nLesson 4 – Collections and iterators  \nCollections  \nThe C\\# Collection classes are a set of classes designed specifically for grouping together objects and performing tasks on them. A number of collection classes are available with C\\# and we will be looking at the key classes in this chapter.  \nBoth the List\u003CT> and ArrayList classes have properties very similar to C\\# arrays. One key advantage of these classes over arrays is that they can grow and shrink as the number of stored objects changes.  \nThe List\u003CT> class is contained with the System .Collections .Generic namespace whilst the ArrayList class is contained within the System .Collections namespace.  \nThe syntax for creating a List\u003CT> collection is as follows:  \nList\u003Ctype> name = new List\u003Ctype>();  \nAn ArrayList object is created in a similar manner, although without the type argument:  \nArrayList name = new ArrayList();  \nWith the above syntax in mind we can now create a List\u003CT> object called colorList:  \nusing System;  \nusing System.Collections.Generic;  \npublic class Lists {  \nstatic void Main()  \n{  \nList\u003Cstring> colorList = new List\u003Cstring>();}  \n}  \nOnce a List object has been created there are a number of methods which may be called to perform tasks on the list. Once such method is the Add() method which, as the name suggests, is used to add items to the list object:  \nList\u003Cstring> colorList = new List\u003Cstring>();  \ncolorList.Add (\"Red\");  \ncolorList.Add (\"Green\");  \ncolorList.Add (\"Yellow\");  \ncolorList.Add (\"Purple\");  \ncolorList.Add (\"Orange\");  \nIndividual items in a list may be accessed using the index value of the item (keeping in mind that the first item is index 0, the second index 1 and so on) . The index value is placed in square brackets after the list name. For example, to access the second item in the colorList object:  \nConsole .WriteLine (colorList[1]);  \nA list item value can similarly be changed using the index combined with the assignment operator. For example, to change the color from Yellow to Ingido:  \nA list item value can similarly be changed using the index combined with the assignment operator. For example, to change the color from Yellow to Ingido:  \ncolorList[2] = \"Indigo\";  \nAll the items in a list may be accessed using a foreach loop. For example:  \nforeach (string color in colorList){  \nConsole .WriteLine ( color );}  \nWhen compiled and executed, the above code will output each of the color strings in the colorList object.  \nItems may be removed from a list using the Remove() method. This method takes the value of the item tobe removed as an argument. For example, to remove the \"Red\" string from the colorList object:  \ncolorList.Remove(\"Red\");  \nIt is important to note that items in a list may be duplicated. In the case of duplicated items, the Remove() method will only remove the first matching instance.  \nPreviously we used the Add() method to add items to a list. The Add() method, however, only adds items to the end of a list. Sometimes it is necessary to insert a new item at a specific location in a list. The Insert() method is provided for this specific purpose. Insert() takes two arguments, an integer indicating the index location of the insertion and the item to be inserted at that location. For example, to insert an item at location 2 in our example list:  \ncolorList.Insert(2, \"White\");  \nThere is no way to tell C\\# to automatically sort a list as items are added. If the items in a list are required tobe always sorted into order the Sort() method should be called after new items are added:  \ncolorList.Sort();  \nA number of methods are provided with the List and ArrayList classes for the purposes of finding items. The most basic method is the Contains() method, which when called on a List or ArrayList object returns true if the specified item is found in the list, or false if it is not.  \nThe IndexOf() method returns the index value of a matching ite","cbCaif2bsxB2MROV","https://ap.wps.com/l/cbCaif2bsxB2MROV","pdf",450955,"English","# Collections\n## List\u003CT> vs ArrayList\n## Adding, accessing, and modifying items\n## foreach and removing/inserting/sorting\n## Searching and index methods\n## Capacity, Count, TrimExcess, Clear\n# Iterators\n## Enumerators","[{\"question\":\"What are the main differences between List\\u003cT\\u003e and ArrayList in this lesson?\",\"answer\":\"List\\u003cT\\u003e is in the System.Collections.Generic namespace, while ArrayList is in System.Collections. They both support similar operations to arrays and can grow or shrink as the stored item count changes.\"},{\"question\":\"How do you access and change items in a C# list by index?\",\"answer\":\"Items are accessed using square brackets after the list name, where the first item is index 0. To change a value, use the index with the assignment operator, e.g., colorList[2] = \\\"Indigo\\\".\"},{\"question\":\"How do IndexOf() and LastIndexOf() help when searching lists?\",\"answer\":\"IndexOf() returns the index of the first matching item, or -1 if the item is not found. LastIndexOf() returns the index of the last matching item, which is useful when duplicates exist.\"}]","Lesson 4 - Collections and iterators | PDF",25,[145],{"page_no":8,"url":146,"width":147,"height":148},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-11-09/ae117936f918b06620065e301526a497.webp",983,1272,{"list":150,"token":66},[151,157,163,169,175,181,187,193,199,205],{"doc_id":152,"doc_title":153,"file_type":137,"home_preview_img_url":154,"slug":155,"view_count":19,"category_name":30,"create_tm":156},685691,"ArrayList and Iterator in Java - Java List Iteration Methods and Examples","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110230000179348/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796111279&Signature=9S61W%2Bc1pMpzzmFXc%2BeGihwgUB0%3D","arraylist-and-iterator-in-java-java-list-iteration-methods-and-examples",1794016767,{"doc_id":158,"doc_title":159,"file_type":137,"home_preview_img_url":160,"slug":161,"view_count":24,"category_name":30,"create_tm":162},685686,"ArrayList in Java","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110230000179246/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796111279&Signature=QLgxLk76B7IDhBLe3jiZmIiTXLA%3D","arraylist-in-java",1794016760,{"doc_id":164,"doc_title":165,"file_type":137,"home_preview_img_url":166,"slug":167,"view_count":29,"category_name":30,"create_tm":168},670910,"Fourth AP Edition - Object-Oriented Programming and Data Structures - Preface xiii","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110229988353200/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796111279&Signature=WwEuBNt85clQBcspSNA9WJ%2FZwhY%3D","fourth-ap-edition-object-oriented-programming-and-data-structures-preface-xiii",1793572671,{"doc_id":170,"doc_title":171,"file_type":137,"home_preview_img_url":172,"slug":173,"view_count":81,"category_name":30,"create_tm":174},685796,"ArrayLists - Introduction to Java ArrayList and Generics","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110230000212466/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796111279&Signature=papgmpFTea81iVTYUgMZ%2BbdmLPk%3D","arraylists-introduction-to-java-arraylist-and-generics",1794018675,{"doc_id":176,"doc_title":177,"file_type":137,"home_preview_img_url":178,"slug":179,"view_count":19,"category_name":30,"create_tm":180},685689,"List and ArrayList - Java Data Structure Overview","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110230000179285/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796111279&Signature=HzyWmBJPnRxFz5i0PCqTfsRkIsI%3D","list-and-arraylist-java-data-structure-overview",1794016763,{"doc_id":182,"doc_title":183,"file_type":137,"home_preview_img_url":184,"slug":185,"view_count":24,"category_name":30,"create_tm":186},671624,"Python Cheat Sheet - Complex Data Types","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110229988737384/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796111279&Signature=ptnb%2Bq65Z1OsGiBRRVI0nmzYiNc%3D","python-cheat-sheet-complex-data-types",1793577649,{"doc_id":188,"doc_title":189,"file_type":137,"home_preview_img_url":190,"slug":191,"view_count":34,"category_name":30,"create_tm":192},685771,"Compound Data - Lists, Tuples, Dictionaries - Unit IV - Learning Notes","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110230000203726/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796111279&Signature=mig2Xk4%2Fc5ZMQIm8XgzSevMWZY4%3D","compound-data-lists-tuples-dictionaries-unit-iv-learning-notes",1794018217,{"doc_id":194,"doc_title":195,"file_type":137,"home_preview_img_url":196,"slug":197,"view_count":34,"category_name":30,"create_tm":198},685695,"High Performance Lists in Java - JavaZone 2015 - Motivation: A Real World Example","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110230000179383/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796111279&Signature=aAOcA6%2BUBePRYL0Cif%2FFt0wbvYM%3D","high-performance-lists-in-java-javazone-2015-motivation-a-real-world-example",1794016775,{"doc_id":200,"doc_title":201,"file_type":137,"home_preview_img_url":202,"slug":203,"view_count":81,"category_name":30,"create_tm":204},685777,"Lists and Tuples - Learn to create and use 1D lists, tuples and 2D lists","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110230000203949/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796111279&Signature=NdAgdq9zphLTZrUrw3CVgvaNkck%3D","lists-and-tuples-learn-to-create-and-use-1d-lists-tuples-and-2d-lists",1794018226,{"doc_id":206,"doc_title":207,"file_type":137,"home_preview_img_url":208,"slug":209,"view_count":14,"category_name":30,"create_tm":210},719605,"Linked Lists - lecture notes","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110230023815899/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796111279&Signature=jceQUOUVmtqxFuRGE%2FtIZQmzOuI%3D","linked-lists-lecture-notes",1795006752]