Différences
Ci-dessous, les différences entre deux révisions de la page.
| Les deux révisions précédentes Révision précédente Prochaine révision | Révision précédente | ||
|
bases_programmation:operations [2017/08/07 18:25] admin [Concaténation] |
bases_programmation:operations [2017/08/07 18:29] (Version actuelle) admin |
||
|---|---|---|---|
| Ligne 30: | Ligne 30: | ||
| ===== Concaténation (Texte) ===== | ===== Concaténation (Texte) ===== | ||
| + | ==== Opérateur + ==== | ||
| + | |||
| + | |||
| + | |||
| <code> | <code> | ||
| string firstString = "Hello"; | string firstString = "Hello"; | ||
| string secondString = "World!"; | string secondString = "World!"; | ||
| string fullString = firstString + " " + secondString; // fullstring vaut "Hello World!" Pensez à ajouter les espaces nécessaires, entre 2 " | string fullString = firstString + " " + secondString; // fullstring vaut "Hello World!" Pensez à ajouter les espaces nécessaires, entre 2 " | ||
| + | </code> | ||
| + | |||
| + | ==== Méthode Concat ==== | ||
| + | <code> | ||
| + | string firstString = "Hello"; | ||
| + | string secondString = "World!"; | ||
| + | string fullstring = string.Concat(firstString, secondString); | ||
| + | </code> | ||
| + | |||
| + | ==== Classe StringBuilder ==== | ||
| + | <code> | ||
| + | string name = "Matt"; | ||
| + | |||
| + | StringBuilder sb = new StringBuilder(); | ||
| + | sb.Append("Hello "); | ||
| + | sb.Append(name); | ||
| + | sb.Append(", comment ça va ?"); | ||
| + | |||
| + | string helloSentence = sb.ToString(); | ||
| </code> | </code> | ||