CKTIS / C#
collections: odniesienie praktyczne
collections: odniesienie praktyczne: Kolekcje modelują kolejność, unikalność, mapowanie i mutowalność danych.
Wersja: C# language and .NET 10 reference runtime
Składnia
// collectionsKolekcje modelują kolejność, unikalność, mapowanie i mutowalność danych.
Dobieraj List, Dictionary, Set, Queue lub typ immutable do potrzebnych operacji.
Zły comparer lub mutowalne klucze psują wyszukiwanie; mutacja unieważnia enumeratory.
Puste kolekcje są normalne, a współbieżny dostęp wymaga właściwego typu lub blokady.
Kompletny program rzeczywiście używa collections; oczekiwany stdout to dokładnie 2.
Przykłady
using System;
using System.Buffers;
using System.Collections.Concurrent;
using System.Collections.Frozen;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Text;
using System.Text.Json;
using System.Text.Json.Nodes;
using System.Text.Json.Serialization;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Channels;
using System.Threading.Tasks;
using Number = System.Int32;
var values = new Dictionary<string, int> { ["a"] = 1 }; values["b"] = 2; Console.WriteLine(values.Count);
Wynik
2
Kompletny program rzeczywiście używa `collections`; oczekiwany stdout to dokładnie `2`.