Getsuyodev, Programming is mainly used when constructing an application. Programming requires knowledge of application domains, algorithms, and programming language expertise. Programming can be developed in different logic based on developer knowledge.

C Sharp – Instruction d’affectation

Programmation en C# (C Sharp)



C# est un langage de la famille des langages hybrides, il possède la notion d’instruction d’affectation.
Le symbole d’affectation en C# est noté ” = ” et peut être utilisé sous plusieurs formes :

Affectation standard :

int x = 56 , y ;
y = x-3 ;

Affectation multiple :

int  x, y, z ;
x = y = z = 56 ;// x, y et z valent 56

Affectation dans une expression :

int  x, y, z = 5 ;
x = z + ( y  = 56 )+2 ; // x vaut 5+56+2=63 et y vaut 56


using System;

class Exercice
{
public static void Main( ) 
{
int x, y, z ;
x = y = z = 56 ;   // x, y et z valent 56
Console.WriteLine("x = "+x+" y = "+y+" z = "+z);

z=5;
x = z + ( y = 56 )+2 ; // x vaut 5+56+2=63 et y vaut 56
Console.WriteLine("x = "+x+" y = "+y+" z = "+z);
Console.ReadLine();
}
}



Comments are closed, but trackbacks and pingbacks are open.

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More