Ignorer les liens de navigationAccueil : Le langage C# : Les conditions : L'instruction if Ignorer les liens de navigation
Accueil
Introduction au Framework .NETDévelopper Introduction au Framework .NET
Le langage C#Développer Le langage C#
Programmation orientée objetsDévelopper Programmation orientée objets
CollectionsDévelopper Collections
ADO.NETDévelopper ADO.NET
LINQDévelopper LINQ
ASP.NETDévelopper ASP.NET
Workflow FoundationDévelopper Workflow Foundation
Besoins de prestationDévelopper Besoins de prestation

L'instruction if en C#

L’instruction if est tout à fait classique. L’exemple suivant détermine la valeur maximum de deux nombres.

 

        int a = 10, b = 12;

        int max;

        if (a > b)

        {

            max = a;

        }

        else

        {

            max = b;

        }

        Console.WriteLine(max);

 

Prenons en compte les points suivants :