C# da Data tiplar haqida

Assalamu aleykum hurmatli dasturchilar, C# tilida ma’lumot turlari (data types) haqida tushuncha beraman. Quyidagi misollar yordamida har bir turdagi o’zgaruvchilarni qanday ishlatishni ko’rsataman.

bool
bool — bu ma’lumot turi true yoki false qiyma…


This content originally appeared on DEV Community and was authored by islomAli99

Assalamu aleykum hurmatli dasturchilar, C# tilida ma'lumot turlari (data types) haqida tushuncha beraman. Quyidagi misollar yordamida har bir turdagi o'zgaruvchilarni qanday ishlatishni ko'rsataman.

  1. bool bool — bu ma'lumot turi true yoki false qiymatlarini saqlaydi.
bool isStudent = true;
bool isTeacher = false;

Console.WriteLine(isStudent);  // Natija: True
Console.WriteLine(isTeacher);  // Natija: False

  1. byte byte — bu 1 baytli butun son bo'lib, qiymati 0 dan 255 gacha bo'lishi mumkin.
byte age = 25;  // 0 dan 255 gacha
Console.WriteLine(age);  // Natija: 25

  1. sbyte sbyte — bu 1 baytli butun son bo'lib, qiymati -128 dan 127 gacha bo'lishi mumkin.
sbyte temperature = -5;  // -128 dan 127 gacha
Console.WriteLine(temperature);  // Natija: -5

  1. short short — bu 2 baytli butun son bo'lib, qiymati -32,768 dan 32,767 gacha bo'lishi mumkin.
short year = 2024;
Console.WriteLine(year);  // Natija: 2024

  1. ushort ushort — bu 2 baytli butun son bo'lib, qiymati 0 dan 65,535 gacha bo'lishi mumkin.
ushort maxScore = 65000;
Console.WriteLine(maxScore);  // Natija: 65000

6.int
int — bu 4 baytli butun son bo'lib, qiymati -2,147,483,648 dan 2,147,483,647 gacha bo'lishi mumkin.

int population = 1000000;
Console.WriteLine(population);  // Natija: 1000000

  1. uint uint — bu 4 baytli butun son bo'lib, qiymati 0 dan 4,294,967,295 gacha bo'lishi mumkin.
uint distance = 3000000000;
Console.WriteLine(distance);  // Natija: 3000000000

  1. long long — bu 8 baytli butun son bo'lib, qiymati -9,223,372,036,854,775,808 dan 9,223,372,036,854,775,807 gacha bo'lishi mumkin.
long worldPopulation = 7800000000;
Console.WriteLine(worldPopulation);  // Natija: 7800000000

  1. ulong ulong — bu 8 baytli butun son bo'lib, qiymati 0 dan 18,446,744,073,709,551,615 gacha bo'lishi mumkin.
ulong starsInGalaxy = 1000000000000000000;
Console.WriteLine(starsInGalaxy);  // Natija: 1000000000000000000

  1. float float — bu 4 baytli suzuvchi nuqtali son bo'lib, qiymati -3.4 * 10^38 dan 3.4 * 10^38 gacha bo'lishi mumkin.
float temperature = 36.6f;
Console.WriteLine(temperature);  // Natija: 36.6

  1. double double — bu 8 baytli suzuvchi nuqtali son bo'lib, qiymati ±5.0 * 10^-324 dan ±1.7 * 10^308 gacha bo'lishi mumkin.
double pi = 3.14159265358979;
Console.WriteLine(pi);  // Natija: 3.14159265358979

  1. decimal decimal — bu 16 baytli o'nli nuqtali son bo'lib, qiymati ±1.0 * 10^-28 dan ±7.9228 * 10^28 gacha bo'lishi mumkin. U 28 ta raqamni aniqlik bilan saqlay oladi.
decimal price = 199.99m;
Console.WriteLine(price);  // Natija: 199.99

  1. char char — bu 2 baytli bir belgini saqlaydi (Unicode kodlashda).
char letter = 'A';
Console.WriteLine(letter);  // Natija: A

  1. string string — bu Unicode belgilardan iborat matnni saqlaydi.
string greeting = "Salom, dunyo!";
Console.WriteLine(greeting);  // Natija: Salom, dunyo!

  1. object object — bu har qanday ma'lumot turini saqlay oladigan umumiy ma'lumot turidir.
object obj1 = 42;
object obj2 = "Hello";
object obj3 = 3.14;

Console.WriteLine(obj1);  // Natija: 42
Console.WriteLine(obj2);  // Natija: Hello
Console.WriteLine(obj3);  // Natija: 3.14

  1. var var — bu ma'lumot turi emas, balki C# sintaksisida turlarni aniqlashni soddalashtiradigan kalit so'zdir. var bilan deklaratsiya qilingan o'zgaruvchining turi kompilyator tomonidan aniqlanadi.
var number = 10;         // int turida
var name = "John";       // string turida
var price = 19.99;       // double turida

Console.WriteLine(number);  // Natija: 10
Console.WriteLine(name);    // Natija: John
Console.WriteLine(price);   // Natija: 19.99

Ushbu misollar yordamida siz har bir ma'lumot turining qanday ishlashini va qanday qiymatlar saqlashini ko'rishingiz mumkin. Har bir tur o'zining maxsus o'lchami va qiymat oralig'iga ega, bu esa dasturchilarga aniqroq va samaraliroq kod yozishga yordam beradi.


This content originally appeared on DEV Community and was authored by islomAli99


Print Share Comment Cite Upload Translate Updates
APA

islomAli99 | Sciencx (2024-07-31T19:35:48+00:00) C# da Data tiplar haqida. Retrieved from https://www.scien.cx/2024/07/31/c-da-data-tiplar-haqida/

MLA
" » C# da Data tiplar haqida." islomAli99 | Sciencx - Wednesday July 31, 2024, https://www.scien.cx/2024/07/31/c-da-data-tiplar-haqida/
HARVARD
islomAli99 | Sciencx Wednesday July 31, 2024 » C# da Data tiplar haqida., viewed ,<https://www.scien.cx/2024/07/31/c-da-data-tiplar-haqida/>
VANCOUVER
islomAli99 | Sciencx - » C# da Data tiplar haqida. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2024/07/31/c-da-data-tiplar-haqida/
CHICAGO
" » C# da Data tiplar haqida." islomAli99 | Sciencx - Accessed . https://www.scien.cx/2024/07/31/c-da-data-tiplar-haqida/
IEEE
" » C# da Data tiplar haqida." islomAli99 | Sciencx [Online]. Available: https://www.scien.cx/2024/07/31/c-da-data-tiplar-haqida/. [Accessed: ]
rf:citation
» C# da Data tiplar haqida | islomAli99 | Sciencx | https://www.scien.cx/2024/07/31/c-da-data-tiplar-haqida/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.