|
Cet article a fait l'objet d'une traduction automatique. Déplacez votre pointeur sur les phrases de l'article pour voir la version originale de ce texte. Informations supplémentaires.
|
Traduction
Source
|
StringBuilder.AppendFormat, méthode (String, Object, Object)
Espace de noms : System.Text
Assembly : mscorlib (dans mscorlib.dll)
Paramètres
- format
- Type : System.String
Chaîne de format composite (consultez Remarques).
- arg0
- Type : System.Object
Premier objet à mettre en forme.
- arg1
- Type : System.Object
Deuxième objet à mettre en forme.
Valeur de retour
Type : System.Text.StringBuilder| Exception | Condition |
|---|---|
| ArgumentNullException | |
| FormatException | |
| ArgumentOutOfRangeException |
Remarque |
|---|
using System; using System.Text; using System.Globalization; class Sample { static StringBuilder sb = new StringBuilder(); public static void Main() { int var1 = 111; float var2 = 2.22F; string var3 = "abcd"; object[] var4 = {3, 4.4, 'X'}; Console.WriteLine(); Console.WriteLine("StringBuilder.AppendFormat method:"); sb.AppendFormat("1) {0}", var1); Show(sb); sb.AppendFormat("2) {0}, {1}", var1, var2); Show(sb); sb.AppendFormat("3) {0}, {1}, {2}", var1, var2, var3); Show(sb); sb.AppendFormat("4) {0}, {1}, {2}", var4); Show(sb); CultureInfo ci = new CultureInfo("es-ES", true); sb.AppendFormat(ci, "5) {0}", var2); Show(sb); } public static void Show(StringBuilder sbs) { Console.WriteLine(sbs.ToString()); sb.Length = 0; } } /* This example produces the following results: StringBuilder.AppendFormat method: 1) 111 2) 111, 2.22 3) 111, 2.22, abcd 4) 3, 4.4, X 5) 2,22 */
Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (rôle principal du serveur non pris en charge), Windows Server 2008 R2 (rôle principal du serveur pris en charge avec SP1 ou version ultérieure ; Itanium non pris en charge)
Le .NET Framework ne prend pas en charge toutes les versions de chaque plateforme. Pour obtenir la liste des versions prises en charge, consultez Configuration requise du .NET Framework.
Remarque