Znalostní bázeCentrum zkoušek
CSČeština
Vybrat jazyk13

CKTIS / C#

System.String: praktická reference

System.String: praktická reference: String je neměnná posloupnost UTF-16; operace při změně obsahu vytvářejí nové řetězce.

Verze: .NET API; verified against .NET 10 reference surface

Syntaxe

System.String /* select a documented member or constructor */

String je neměnná posloupnost UTF-16; operace při změně obsahu vytvářejí nové řetězce.

Použijte pro text a výslovně zvolte kulturu i způsob porovnání.

Length počítá kódové jednotky UTF-16, ne grafémy; spojování ve smyčce může hodně alokovat.

Prázdný string se liší od null a znaky mimo BMP zabírají pár surrogate.

Úplný program skutečně používá System.String; přesně očekávaný stdout je C-sharp.

Příklady

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 text = string.Join("-", new[] { "C", "sharp" });
Console.WriteLine(text);

Výsledek

C-sharp

Úplný program skutečně používá `System.String`; přesně očekávaný stdout je `C-sharp`.

Zdroje