16-Maruza: Kortejlar


var tuple = ("Alex", 36); (string


Download 19.01 Kb.
bet3/3
Sana08.04.2023
Hajmi19.01 Kb.
#1341516
1   2   3
Bog'liq
16-Ma\'ruza matni

var tuple = ("Alex", 36);
(string name, int age) = tuple;
//или
string name;
int age;
(name, age) = tuple;
Tenglik uchun kortejlarni tekshirish
var tuple1 = (23, 36);
var tuple2 = (17, 31);
Console.WriteLine(tuple1 == tuple2);
Console.WriteLine(tuple1 != tuple2);
Taqqoslashda maydon nomlari hisobga olinmaydi.

Kortejlarni solishtirish imkoniyati uchun shartlar:


Ikkala kortej ham bir xil miqdordagi elementlarni o'z ichiga oladi.


var limitsLookup = new Dictionary<int, (int Min, int Max)>()
{
[2] = (4, 10),
[4] = (10, 20),
[6] = (0, 23)
};


if (limitsLookup.TryGetValue(4, out (int Min, int Max) limits))
{
Console.WriteLine($"Found limits: min is {limits.Min}, max is {limits.Max}");
}
Download 19.01 Kb.

Do'stlaringiz bilan baham:
1   2   3




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling