System
The standard library: collections (List, Dictionary, HashSet, Stack, Queue), text (StringBuilder,
Encoding, Regex, JsonValue), files and folders (File, Directory, Path, FileStream,
StreamReader, StreamWriter), time (DateTime, TimeSpan, Stopwatch), processes, random numbers and
threads (Thread, Mutex).
using System;
int Main(){ var names = List<string>.Create(); names.Add("Ann"); Console.WriteLine(names[0]); return 0;}Functions that can fail return typed results, e.g. IoError<string> from File.ReadAllText: the value or one of
the codes of an error enum (IoError, ParseError, EncodingError, JsonError, RegexError).
| Type | Description |
|---|---|
TimeSpan |
A duration (or a time of day): a signed number of ticks of 100 ns, like .NET’s TimeSpan (with methods instead of properties). |
DateTime |
A date and time of day, local or UTC. |
Stopwatch |
Measures elapsed time with the monotonic clock of the system (not affected by changes of the time of day). |
KeyValuePair<TKey, |
A key and its value, from Dictionary<TKey, TValue>.Entries. |
Dictionary<TKey, |
A hash table (separate chaining). |
Path |
File names and paths, as strings: Path.Combine("src", "main.cshift"), Path.GetExtension(file), … |
Directory |
Directories and file names. |
Encoding |
Conversion between strings (always UTF-8 in memory) and raw bytes. |
File |
Whole files: reading, writing, copying, moving and deleting them (static functions). |
HashSet<T> |
A set of values (T must be a valid Dictionary key: numbers, bool, char, enums, string, or a struct with GetHashCode/Equals). |
JsonValue |
Reading (Json.Parse), building and writing (JsonValue.ToString / ToIndentedString). |
Json |
Reading JSON text: see Json.Parse and JsonValue. |
List<T> |
A growable array. |
Mutex<T> |
A value that several threads share, guarded by a lock. |
MutexGuard<T> |
Holds the lock of a Mutex<T> until Dispose(). |
Process |
Runs other programs and reads environment variables (static functions). |
Queue<T> |
A queue of values: first in, first out. |
Random |
Pseudo-random numbers (xorshift64*, seeded with SplitMix64). |
RegexMatch |
A match of a Regex: where it is, its text and the text of its groups. |
Regex |
Regular expressions: matching, searching, replacing and splitting text. |
Stack<T> |
A stack of values: last in, first out. |
FileStream |
A file, read and written as bytes, with seeking. |
StreamReader |
Reads a UTF-8 text file line by line (or all of it). |
StreamWriter |
Writes text to a file as UTF-8. |
StringBuilder |
Builds a string without copying it for every ‘+’. |
Thread<T> |
The handle of a running thread function that returns a T: start Square(6) runs thread int Square(int x) on its own OS thread and returns a Thread<int> right away. |
DayOfWeek |
The days of the week, with the numbers of .NET (Sunday is 0). |
EncodingKind |
The encodings that Encoding knows. |
IoError |
The errors of file and folder operations (File, Directory, FileStream). |
ParseError |
The errors of parsing numbers (String.ParseInt, String.ParseInt64, String.ParseDouble). |
EncodingError |
The errors of decoding bytes into text (Encoding.GetString). |
JsonKind |
The kind of a JsonValue. |
JsonError |
The errors of Json.Parse; the message says where the problem is (line and column). |
RegexError |
The error of Regex.Create. |
SeekOrigin |
Where FileStream.Seek counts from. |