
C# Programlama – Break Keyword
Ocak 2, 2022
C# Programlama – Name Space Kavramı
Ocak 2, 2022C# Programlama - Operators
Operators Örnekler:
using System;
namespace ConsoleApp1
{
class Program
{
static void Main(string[] args)
{
//******************AritmetichsOperators****************
int x = 10;
int y = 20;
int z = 30;
Console.WriteLine(string.Format("x * y : {0}", x * y));
Console.WriteLine(string.Format("x + y : {0}", x + y));
Console.WriteLine(string.Format("x - y : {0}", x - y));
Console.WriteLine(string.Format("x / y : {0}", x / y));
Console.WriteLine(string.Format("x % y : {0}", x % y));
Console.WriteLine(string.Format("++y : {0}", ++y));
Console.WriteLine(string.Format("y++ : {0}", y++));
Console.WriteLine(string.Format("--y : {0}", --y));
Console.WriteLine(string.Format("z-- : {0}", z--));
Console.ReadKey();
//******************AssignmentOperators******************
int a = 50;
int b = 100;
int c = 150;
int d = 200;
Console.WriteLine(string.Format("a += b : {0}", a += b));
Console.WriteLine(string.Format("a -= b : {0}", a -= b));
Console.WriteLine(string.Format("a *= b : {0}", a *= b));
Console.WriteLine(string.Format("a /= b : {0}", a /= b));
Console.WriteLine(string.Format("c %= d : {0}", c %= d));
Console.WriteLine(string.Format("a = b : {0}", a = b));
Console.ReadKey();
//*****************ComparisonOperators*********************
var m = 5;
var n = 10;
var o = n;
Console.WriteLine(string.Format("m == n : {0}", m == n));
Console.WriteLine(string.Format("n == o : {0}", n == o));
if (n == o)
{
Console.WriteLine("n, o'ya eşittir.");
}
else
{
Console.WriteLine("n, o'ya eşit değildir.");
}
Console.WriteLine(string.Format("m != o : {0}", m == o));
Console.WriteLine(string.Format("m > o : {0}", m > o));
Console.WriteLine(string.Format("m < o : {0}", m < o));
Console.WriteLine(string.Format("m <= o : {0}", m <= o));
Console.WriteLine(string.Format("m >= o : {0}", m >= o));
Console.ReadKey();
//****************LogicalOperators*************************
var p = true;
var q = false;
Console.WriteLine(string.Format("p && q : {0}", p && q));
p = false;
Console.WriteLine(string.Format("p && q : {0}", p && q));
q = true;
Console.WriteLine(string.Format("p && q : {0}", p && q));
p = true;
Console.WriteLine(string.Format("p || q : {0}", p || q));
q = false;
Console.WriteLine(string.Format("p || q : {0}", p || q));
Console.WriteLine(string.Format("!a : {0}", !p));
}
}
}