//Langage C#
int age;
string prenom;
//Langage C#
age = 30;
prenom = "nicolas";
//Langage C#
int age = 20; // Déclaration et affectation en une seule ligne
age = age + 10; // age contient 30 (addition)
age++; // age contient 31 (incrémentation de 1)
age--; // age contient 30 (décrémentation de 1)
age += 10; // équivalent à age = age + 10 (age contient 40)
age /= 2; // équivalent à age = age / 2 => (age contient 20)
age *= 3; // équivalent à age = age * 3 => (age contient 60)
Opérateur +
string firstString = "Hello";
string secondString = "World!";
string fullString = firstString + " " + secondString; // fullstring vaut "Hello World!" Pensez à ajouter les espaces nécessaires, entre 2 "
Méthode Concat
string firstString = "Hello";
string secondString = "World!";
string fullstring = string.Concat(firstString, secondString);
Classe StringBuilder
string name = "Matt";
StringBuilder sb = new StringBuilder();
sb.Append("Hello ");
sb.Append(name);
sb.Append(", comment ça va ?");
string helloSentence = sb.ToString();
Opérateur | Description |
== | Egalité |
!= | Différence |
> | Supérieur à |
< | Inférieur à |
>= | Supérieur ou égal |
⇐ | Inférieur ou égal |
&& | ET logique |
|| | OU logique |
! | Négation |