C# Koşul Operatörü

S

Spectrum Artz

Web | Graphics
Ultra Member
Joined
Jul 31, 2019
Messages
525
Reaction score
111
? : Operatörü
Koşul operatör if else deyiminin kısa yazımı olarak kullanılır. Karar yapılarını hakkında bilginiz yoksa yukarıdaki if else ifadesine tıklayın.

Koşul Operatörü



Code:
Ifade1? Ifade2: Ifade3;


Ifade1, Ifade2 ve Ifade3 ifadelerinin yerleşimine dikkat ederek aşağıdaki açıklamayı okuyun.

Koşul Ifade1 değeridir. Koşulun doğru olması durumunda deyimden dönen değeri Ifade2, koşulun yanlış olması durumunda deyimden dönecek olan değeri Ifade3 olacaktır.

Örnek:


Code:
// ?: koşullu operatör kullanımı
string durum;
int sayi;
 
sayi=  10;
durum= (sayi> 0) ? "pozitif" : "negatif";



Örnek: Yukarıdaki kodun if else yazımı


Code:
// if else kullanımı
string durum;
int sayi;
 
sayi=  10;
if(sayi > 0)
   durum="pozitif";
else
  durum="negatif";

11


 
SPAM IS FORBIDDEN!
  • SPAMMERS ARE BANNED FROM THE FORUM AND CANNOT USE ANY OF THE CHEATS
  • For example: thanks, thx, very good, asdqwe, working, ty and so on!
  • For example: Writing the same message over and over. thanks, thx and so on!
  • Copying and copying someone else's message is prohibited.
  • It is forbidden to send messages to increase the number of comments on threads that you have no knowledge of.
  • Write your own opinion when commenting!
  • If you see spam message, please let us know with the REPORT button!

Tema düzenleyici

Top Bottom