1
0
mirror of https://github.com/adambard/learnxinyminutes-docs.git synced 2025-08-17 04:04:20 +02:00

swithc case

This commit is contained in:
Melih Mucuk
2014-12-31 16:46:49 +02:00
parent 20a921fd03
commit 4ba98e1b97

View File

@@ -141,46 +141,46 @@ on a new line! ""Wow!"", the masses cried";
// Bir diğer dizi tanımlama formatı şöyledir: // Bir diğer dizi tanımlama formatı şöyledir:
int[] y = { 9000, 1000, 1337 }; int[] y = { 9000, 1000, 1337 };
// Indexing an array - Accessing an element // Bir diziyi indeksleme - Bir elemente erişme
Console.WriteLine("intArray @ 0: " + intArray[0]); Console.WriteLine("intArray @ 0: " + intArray[0]);
// Arrays are mutable. // Diziler değiştirilebilir.
intArray[1] = 1; intArray[1] = 1;
// Lists // Listeler
// Lists are used more frequently than arrays as they are more flexible // Listeler daha esnek oldukları için dizilerden daha sık kullanılırlar.
// The format for declaring a list is follows: // Bir liste tanımlama formatı şöyledir:
// List<datatype> <var name> = new List<datatype>(); // List<veri tipi> <değişken ismi> = new List<veri tipi>();
List<int> intList = new List<int>(); List<int> intList = new List<int>();
List<string> stringList = new List<string>(); List<string> stringList = new List<string>();
List<int> z = new List<int> { 9000, 1000, 1337 }; // intialize List<int> z = new List<int> { 9000, 1000, 1337 }; // tanımlama
// The <> are for generics - Check out the cool stuff section // <> areti genelleme içindir - Güzel özellikler sekmesini inceleyin
// Lists don't default to a value; // Listelerin varsayılan bir değeri yoktur;
// A value must be added before accessing the index // İndekse erişmeden önce değer eklenmiş olmalıdır
intList.Add(1); intList.Add(1);
Console.WriteLine("intList @ 0: " + intList[0]); Console.WriteLine("intList @ 0: " + intList[0]);
// Others data structures to check out: // Diğer veri yapıları için şunlara bakın:
// Stack/Queue // Stack/Queue (Yığın/Kuyruk)
// Dictionary (an implementation of a hash map) // Dictionary (hash map'in uygulanması) (Sözlük)
// HashSet // HashSet (karma seti)
// Read-only Collections // Read-only Collections (Değiştirilemez koleksiyonlar)
// Tuple (.Net 4+) // Tuple (.Net 4+) (tüp)
/////////////////////////////////////// ///////////////////////////////////////
// Operators // Operatörler
/////////////////////////////////////// ///////////////////////////////////////
Console.WriteLine("\n->Operators"); Console.WriteLine("\n->Operators");
int i1 = 1, i2 = 2; // Shorthand for multiple declarations int i1 = 1, i2 = 2; // Birden çok tanımlamanın kısa yolu
// Arithmetic is straightforward // Aritmetik basittir
Console.WriteLine(i1 + i2 - i1 * 3 / 7); // => 3 Console.WriteLine(i1 + i2 - i1 * 3 / 7); // => 3
// Modulo // Mod
Console.WriteLine("11%3 = " + (11 % 3)); // => 2 Console.WriteLine("11%3 = " + (11 % 3)); // => 2
// Comparison operators // Karşılaştırma operatörleri
Console.WriteLine("3 == 2? " + (3 == 2)); // => false Console.WriteLine("3 == 2? " + (3 == 2)); // => false
Console.WriteLine("3 != 2? " + (3 != 2)); // => true Console.WriteLine("3 != 2? " + (3 != 2)); // => true
Console.WriteLine("3 > 2? " + (3 > 2)); // => true Console.WriteLine("3 > 2? " + (3 > 2)); // => true
@@ -188,17 +188,17 @@ on a new line! ""Wow!"", the masses cried";
Console.WriteLine("2 <= 2? " + (2 <= 2)); // => true Console.WriteLine("2 <= 2? " + (2 <= 2)); // => true
Console.WriteLine("2 >= 2? " + (2 >= 2)); // => true Console.WriteLine("2 >= 2? " + (2 >= 2)); // => true
// Bitwise operators! // Bit düzeyi operatörleri!
/* /*
~ Unary bitwise complement ~ Tekli bit tamamlayıcısı
<< Signed left shift << Sola kaydırma Signed left shift
>> Signed right shift >> Sağa kaydırma Signed right shift
& Bitwise AND & Bit düzeyi AND
^ Bitwise exclusive OR ^ Bit düzeyi harici OR
| Bitwise inclusive OR | Bit düzeyi kapsayan OR
*/ */
// Incrementations // Arttırma
int i = 0; int i = 0;
Console.WriteLine("\n->Inc/Dec-rementation"); Console.WriteLine("\n->Inc/Dec-rementation");
Console.WriteLine(i++); //i = 1. Post-Incrementation Console.WriteLine(i++); //i = 1. Post-Incrementation
@@ -207,11 +207,11 @@ on a new line! ""Wow!"", the masses cried";
Console.WriteLine(--i); //i = 0. Pre-Decrementation Console.WriteLine(--i); //i = 0. Pre-Decrementation
/////////////////////////////////////// ///////////////////////////////////////
// Control Structures // Kontrol Yapıları
/////////////////////////////////////// ///////////////////////////////////////
Console.WriteLine("\n->Control Structures"); Console.WriteLine("\n->Control Structures");
// If statements are c-like // If ifadesi c benzeridir
int j = 10; int j = 10;
if (j == 10) if (j == 10)
{ {
@@ -226,47 +226,47 @@ on a new line! ""Wow!"", the masses cried";
Console.WriteLine("I also don't"); Console.WriteLine("I also don't");
} }
// Ternary operators // Üçlü operatörler
// A simple if/else can be written as follows // Basit bir if/else ifadesi şöyle yazılabilir
// <condition> ? <true> : <false> // <koşul> ? <true> : <false>
string isTrue = (true) ? "True" : "False"; string isTrue = (true) ? "True" : "False";
// While loop // While döngüsü
int fooWhile = 0; int fooWhile = 0;
while (fooWhile < 100) while (fooWhile < 100)
{ {
//Iterated 100 times, fooWhile 0->99 //100 kere tekrarlanır, fooWhile 0->99
fooWhile++; fooWhile++;
} }
// Do While Loop // Do While Döngüsü
int fooDoWhile = 0; int fooDoWhile = 0;
do do
{ {
//Iterated 100 times, fooDoWhile 0->99 //100 kere tekrarlanır, fooDoWhile 0->99
fooDoWhile++; fooDoWhile++;
} while (fooDoWhile < 100); } while (fooDoWhile < 100);
//for loop structure => for(<start_statement>; <conditional>; <step>) //for döngüsü yapısı => for(<başlangıç ifadesi>; <koşul>; <adım>)
for (int fooFor = 0; fooFor < 10; fooFor++) for (int fooFor = 0; fooFor < 10; fooFor++)
{ {
//Iterated 10 times, fooFor 0->9 //10 kere tekrarlanır, fooFor 0->9
} }
// For Each Loop // For Each Döngüsü
// foreach loop structure => foreach(<iteratorType> <iteratorName> in <enumerable>) // foreach döngüsü yapısı => foreach(<yineleyici tipi> <yineleyici ismi> in <enumerable>)
// The foreach loop loops over any object implementing IEnumerable or IEnumerable<T> // foreach döngüsü, IEnumerable ya da IEnumerable<T> e dönüştürülmüş herhangi bir obje üzerinde döngü yapabilir
// All the collection types (Array, List, Dictionary...) in the .Net framework // .Net framework üzerindeki bütün koleksiyon tiplerinden (Dizi, Liste, Sözlük...)
// implement one or both of these interfaces. // biri ya da hepsi uygulanarak gerçekleştirilebilir.
// (The ToCharArray() could be removed, because a string also implements IEnumerable) // (ToCharArray() silindi, çünkü string'ler aynı zamanda IEnumerable'dır.)
foreach (char character in "Hello World".ToCharArray()) foreach (char character in "Hello World".ToCharArray())
{ {
//Iterated over all the characters in the string //String içindeki bütün karakterler üzerinde döner
} }
// Switch Case // Switch Case
// A switch works with the byte, short, char, and int data types. // Bir switch byte, short, char ve int veri tipleri ile çalışır.
// It also works with enumerated types (discussed in Enum Types), // Aynı zamanda sıralı tipler ilede çalışabilir.(Enum Tipleri bölümünde tartışıldı),
// the String class, and a few special classes that wrap // the String class, and a few special classes that wrap
// primitive types: Character, Byte, Short, and Integer. // primitive types: Character, Byte, Short, and Integer.
int month = 3; int month = 3;