{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "be59114d-a4b7-4f90-a5b5-b7648d87f5be",
   "metadata": {},
   "source": "# Preview Questions\n\nComplete these questions **before** class to prepare for the chapter.\nUse the dropdowns to check your answers.\n"
  },
  {
   "cell_type": "markdown",
   "id": "90eb2792-e928-4a45-84a2-ea7d189305fd",
   "metadata": {},
   "source": "## True or False\n\n**1.** `StreamReader` is used to write data to a file.\n\n```{dropdown} Answer\n**False** — `StreamReader` reads; use `StreamWriter` to write.\n```\n\n**2.** You should close a file stream after you are done using it.\n\n```{dropdown} Answer\n**True** — Unclosed streams can cause resource leaks or data loss.\n```\n\n**3.** `File.ReadAllText()` reads the entire file into a single string.\n\n```{dropdown} Answer\n**True** — It returns all file content as one `string`.\n```\n\n**4.** Regular expressions can only match exact strings, not patterns.\n\n```{dropdown} Answer\n**False** — Regex is designed to match patterns, not just literal strings.\n```\n\n**5.** The `using` statement ensures a resource is disposed when the block exits.\n\n```{dropdown} Answer\n**True** — `using` calls `Dispose()` automatically, even on exceptions.\n```\n\n"
  },
  {
   "cell_type": "markdown",
   "id": "f82301a3-78de-4190-af9a-0fc7a24635ae",
   "metadata": {},
   "source": "## Multiple Choice\n\n**1.** Which C# class reads text line by line from a file?\n\na) FileWriter  \nb) StreamReader  \nc) FileInput  \nd) TextGetter\n\n```{dropdown} Answer\n**b) StreamReader** — `StreamReader` wraps a file and exposes `ReadLine()` and `ReadToEnd()`.\n```\n\n**2.** Which namespace contains file I/O classes in C#?\n\na) System.IO  \nb) System.File  \nc) System.Text  \nd) System.Storage\n\n```{dropdown} Answer\n**a) System.IO** — `System.IO` contains `StreamReader`, `StreamWriter`, `File`, etc.\n```\n\n**3.** What does `StreamWriter.WriteLine(text)` do?\n\na) Reads a line  \nb) Writes text followed by a newline  \nc) Deletes a line  \nd) Counts lines in a file\n\n```{dropdown} Answer\n**b) Writes text followed by a newline** — It writes the string and appends the platform's newline character.\n```\n\n**4.** What does `File.Exists(path)` return if the file is not found?\n\na) null  \nb) 0  \nc) false  \nd) throws an exception\n\n```{dropdown} Answer\n**c) false** — `File.Exists()` returns `false` for missing files — it never throws.\n```\n\n**5.** In a regular expression, what does the pattern `\\d+` match?\n\na) Any letter  \nb) One or more digits  \nc) Whitespace  \nd) Any character\n\n```{dropdown} Answer\n**b) One or more digits** — `\\d` matches a digit; `+` means one or more.\n```\n\n"
  },
  {
   "cell_type": "markdown",
   "id": "91fd6df4-ddeb-4158-96cf-2cfa0115a2cf",
   "metadata": {},
   "source": "```{rubric} Footnotes\n```\n"
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": ".NET (C#)",
   "language": "C#",
   "name": ".net-csharp"
  },
  "language_info": {
   "name": "csharp"
  },
  "polyglot_notebook": {
   "kernelInfo": {
    "defaultKernelName": "csharp",
    "items": [
     {
      "aliases": [],
      "name": "csharp"
     }
    ]
   }
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
