{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "3a8a4534",
   "metadata": {},
   "source": [
    "# Chapter Review\n",
    "\n",
    "01. Distinguish the cases when you would want to use a list instead of an array, or\n",
    "    the other way around.\n",
    "\n",
    "02. What syntax is consistent between arrays and lists? What are comparable\n",
    "    features, but with different syntax?\n",
    "\n",
    "03. Here is one way to put five particular elements into a list:\n",
    "\n",
    "    > ```\n",
    "    > var words = new List<string>();\n",
    "    > string[] temp = {\"a\", \"an\", \"the\", \"on\", \"of\"};\n",
    "    > foreach(string s in temp) {\n",
    "    >     words.Add(s);\n",
    "    > }\n",
    "    > ```\n",
    "    >\n",
    "    > How can you do this all without a loop, and with only two statements?\n",
    "    > How about with a single statement, assuming you do not need temp again?\n",
    "\n",
    "04. If we continue on from above, with the line:\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "beaeb5b9",
   "metadata": {
    "language_info": {
     "name": "polyglot-notebook"
    },
    "polyglot_notebook": {
     "kernelName": "csharp"
    },
    "vscode": {
     "languageId": "polyglot-notebook"
    }
   },
   "outputs": [],
   "source": [
    "    var words2 = words;\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "140dab46",
   "metadata": {},
   "source": [
    "\n",
    "    Then what would be the difference in effect between these two possible next\n",
    "    lines?\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "a7704540",
   "metadata": {
    "language_info": {
     "name": "polyglot-notebook"
    },
    "polyglot_notebook": {
     "kernelName": "csharp"
    },
    "vscode": {
     "languageId": "polyglot-notebook"
    }
   },
   "outputs": [],
   "source": [
    "    words.Clear()\n",
    "\n",
    "    words = new List<string>();\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "8daa7e38",
   "metadata": {},
   "source": [
    "\n",
    "05. If you delete an element from the middle of a list, what happens to the\n",
    "    spot where you removed the element?\n",
    "\n",
    "06. Which is true for a `Dictionary`: is it mutable or immutable?\n",
    "\n",
    "07. What syntax is there for a `Dictionary` that matches that for a `List`?\n",
    "\n",
    "08. You have been using csharprepl and it currently shows the following:\n",
    "\n",
    "    > ```none\n",
    "    > > words\n",
    "    > List<string>(3)\n",
    "    > ┌──────┬──────────┬────────┐\n",
    "    > │ Name │ Value    │ Type   │\n",
    "    > ├──────┼──────────┼────────┤\n",
    "    > │ [0]  │ \"Apple\"  │ string │\n",
    "    > │ [1]  │ \"Banana\" │ string │\n",
    "    > │ [2]  │ \"Cherry\" │ string │\n",
    "    > └──────┴──────────┴────────┘\n",
    "    > ```\n",
    "\n",
    "    What would `words.Count` return in csharprepl?\n",
    "\n",
    "09. In VS Code, create a method call SortFruits. When called with a string array\n",
    "    argument that contains three fruit names, the method:\n",
    "\n",
    "    - turns the fruits into a string list,\n",
    "    - print out the data type of the list (use .GetType()),\n",
    "    - sort the fruits alphabetically, and\n",
    "    - iterate through the list and print out the sorted fruit names, but\n",
    "    - does not return anything to the caller.\n",
    "\n",
    "10. In csharprepl, create a dictionary of key-value \\<string, string>, call it fruits,\n",
    "    that contains three fruits and their corresponding color. Iterate through\n",
    "    the dictionary and output each entry in one line formatted as \"\\<fruit>\" : \"\\<color>\".\n",
    "    Afterwards, print your full name in a separate line.\n",
    "\n",
    "% #.  Though for some collections, like arrays and lists,\n",
    "\n",
    "% you can fairly easily replace a ``foreach``\n",
    "\n",
    "% loop with a ``for`` loop, that is not the case if you want to iterate\n",
    "\n",
    "% through a ``Dictionary``.  How do you go through all the keys in\n",
    "\n",
    "% a ``Dictionary``?\n",
    "\n",
    "% #.  ``Dictionary`` values are of arbitrary type. What is the restriction on\n",
    "\n",
    "% key types?"
   ]
  }
 ],
 "metadata": {
  "jupytext": {
   "cell_metadata_filter": "-all",
   "main_language": "python",
   "notebook_metadata_filter": "-all"
  },
  "kernelspec": {
   "display_name": ".NET (C#)",
   "language": "C#",
   "name": ".net-csharp"
  },
  "language_info": {
   "name": "csharp"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
