mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2025-08-06 06:47:54 +02:00
arrays
This commit is contained in:
@@ -82,63 +82,63 @@ namespace Learning
|
|||||||
long fooLong = 100000L; // (-9,223,372,036,854,775,808 <= long <= 9,223,372,036,854,775,807)
|
long fooLong = 100000L; // (-9,223,372,036,854,775,808 <= long <= 9,223,372,036,854,775,807)
|
||||||
ulong fooUlong = 100000L; // (0 <= ulong <= 18,446,744,073,709,551,615)
|
ulong fooUlong = 100000L; // (0 <= ulong <= 18,446,744,073,709,551,615)
|
||||||
// Sayılar boyutlarına göre ön tanımlı olarak int ya da uint olabilir.
|
// Sayılar boyutlarına göre ön tanımlı olarak int ya da uint olabilir.
|
||||||
// L, bir değerin long ya da ulong tipinde olduğunu belirtmek için kullanılır.
|
// L, değişken değerinin long ya da ulong tipinde olduğunu belirtmek için kullanılır.
|
||||||
|
|
||||||
// Double - Double-precision 64-bit IEEE 754 Floating Point
|
// Double - Çift hassasiyetli 64-bit IEEE 754 kayan sayı
|
||||||
double fooDouble = 123.4; // Precision: 15-16 digits
|
double fooDouble = 123.4; // Hassasiyet: 15-16 basamak
|
||||||
|
|
||||||
// Float - Single-precision 32-bit IEEE 754 Floating Point
|
// Float - Tek hassasiyetli 32-bit IEEE 754 kayan sayı
|
||||||
float fooFloat = 234.5f; // Precision: 7 digits
|
float fooFloat = 234.5f; // Hassasiyet: 7 basamak
|
||||||
// f is used to denote that this variable value is of type float
|
// f, değişken değerinin float tipinde olduğunu belirtmek için kullanılır.
|
||||||
|
|
||||||
// Decimal - a 128-bits data type, with more precision than other floating-point types,
|
// Decimal - 128-bit veri tiğinde ve diğer kayan sayı veri tiplerinden daha hassastır,
|
||||||
// suited for financial and monetary calculations
|
// finansal ve mali hesaplamalar için uygundur.
|
||||||
decimal fooDecimal = 150.3m;
|
decimal fooDecimal = 150.3m;
|
||||||
|
|
||||||
// Boolean - true & false
|
// Boolean - true & false
|
||||||
bool fooBoolean = true; // or false
|
bool fooBoolean = true; // veya false
|
||||||
|
|
||||||
// Char - A single 16-bit Unicode character
|
// Char - 16-bitlik tek bir unicode karakter
|
||||||
char fooChar = 'A';
|
char fooChar = 'A';
|
||||||
|
|
||||||
// Strings -- unlike the previous base types which are all value types,
|
// Strings -- Önceki baz tiplerinin hepsi değer tipiyken,
|
||||||
// a string is a reference type. That is, you can set it to null
|
// string bir referans tipidir. Null değer atayabilirsiniz
|
||||||
string fooString = "\"escape\" quotes and add \n (new lines) and \t (tabs)";
|
string fooString = "\"escape\" quotes and add \n (new lines) and \t (tabs)";
|
||||||
Console.WriteLine(fooString);
|
Console.WriteLine(fooString);
|
||||||
|
|
||||||
// You can access each character of the string with an indexer:
|
// İndeks numarası kullanarak bir string'in bütün karakterlerine erişilebilirsiniz:
|
||||||
char charFromString = fooString[1]; // => 'e'
|
char charFromString = fooString[1]; // => 'e'
|
||||||
// Strings are immutable: you can't do fooString[1] = 'X';
|
// String'ler değiştirilemez: fooString[1] = 'X' işlemini yapamazsınız;
|
||||||
|
|
||||||
// Compare strings with current culture, ignoring case
|
// String'leri geçerli kültür değeri ve büyük küçük harf duyarlılığı olmadan karşılaştırma
|
||||||
string.Compare(fooString, "x", StringComparison.CurrentCultureIgnoreCase);
|
string.Compare(fooString, "x", StringComparison.CurrentCultureIgnoreCase);
|
||||||
|
|
||||||
// Formatting, based on sprintf
|
// sprintf baz alınarak formatlama
|
||||||
string fooFs = string.Format("Check Check, {0} {1}, {0} {1:0.0}", 1, 2);
|
string fooFs = string.Format("Check Check, {0} {1}, {0} {1:0.0}", 1, 2);
|
||||||
|
|
||||||
// Dates & Formatting
|
// Tarihler & Formatlama
|
||||||
DateTime fooDate = DateTime.Now;
|
DateTime fooDate = DateTime.Now;
|
||||||
Console.WriteLine(fooDate.ToString("hh:mm, dd MMM yyyy"));
|
Console.WriteLine(fooDate.ToString("hh:mm, dd MMM yyyy"));
|
||||||
|
|
||||||
// You can split a string over two lines with the @ symbol. To escape " use ""
|
// Bir string'i iki satıra bölmek için @ sembolü kullanabilirsiniz. " işaretinden kaçmak için "" kullanın
|
||||||
string bazString = @"Here's some stuff
|
string bazString = @"Here's some stuff
|
||||||
on a new line! ""Wow!"", the masses cried";
|
on a new line! ""Wow!"", the masses cried";
|
||||||
|
|
||||||
// Use const or read-only to make a variable immutable
|
// Bir değişkeni değiştirilemez yapmak için const ya da read-only kullanın.
|
||||||
// const values are calculated at compile time
|
// const değerleri derleme sırasında hesaplanır
|
||||||
const int HOURS_I_WORK_PER_WEEK = 9001;
|
const int HOURS_I_WORK_PER_WEEK = 9001;
|
||||||
|
|
||||||
///////////////////////////////////////////////////
|
///////////////////////////////////////////////////
|
||||||
// Data Structures
|
// Veri Yapıları
|
||||||
///////////////////////////////////////////////////
|
///////////////////////////////////////////////////
|
||||||
|
|
||||||
// Arrays - zero indexed
|
// Diziler - Sıfır indeksli
|
||||||
// The array size must be decided upon declaration
|
// Dizi boyutuna tanımlama sırasında karar verilmelidir.
|
||||||
// The format for declaring an array is follows:
|
// Dizi tanımlama formatı şöyledir:
|
||||||
// <datatype>[] <var name> = new <datatype>[<array size>];
|
// <veri tipi>[] <değişken ismi> = new <veri tipi>[<dizi boyutu>];
|
||||||
int[] intArray = new int[10];
|
int[] intArray = new int[10];
|
||||||
|
|
||||||
// Another way to declare & initialize an array
|
// Bir diğer dizi tanımlama formatı şöyledir:
|
||||||
int[] y = { 9000, 1000, 1337 };
|
int[] y = { 9000, 1000, 1337 };
|
||||||
|
|
||||||
// Indexing an array - Accessing an element
|
// Indexing an array - Accessing an element
|
||||||
|
Reference in New Issue
Block a user