FR CSharp Operator Interpolation - LIHACHTETAN/ClassicUO-Bad-Newbie-CSharp-Scripts-IDE GitHub Wiki
Українська · Русский · English · Deutsch · Français · Italiano · Español · 繁體中文 · 日本語 · 한국어
Formulaires de lignes
L'interpolation calcule les insertions dans une chaîne ; verbatim préserve les barres obliques inverses ; Le littéral brut facilite les guillemets imbriqués et le texte multiligne.
Exemple simple (Example.cs)
Enregistrez cet exemple séparément dans Example.cs. Exécutez-le indépendamment des autres exemples de cette page.
Example.cs:
// PROJECT-EXAMPLE
int count = 3;
System.Console.WriteLine($"Count={count}");
Résultat:
Count=3
Syntaxe
$"{value:format}" / @"text" / """text"""
Exemple 1
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using System.IO;
using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;
public static class Program
{
public static async Task Main(string[] args)
{
decimal amount = 12.5M;
string text = $"Amount: {amount:F2}";
Console.WriteLine(text);
Console.WriteLine(@"C:\Scripts\Data");
}
}
Exemple 2
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using System.IO;
using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;
public static class Program
{
public static async Task Main(string[] args)
{
string json = """{"name":"ore","count":3}""";
Console.WriteLine(json);
}
}
Source officielle : Microsoft Apprendre.