DEV Community

Sunnat Qayumov
Sunnat Qayumov

Posted on

C# - Input.

C# dasturlash tilida input qilish uchun Console.ReadLine() funcsiyasidan foydalanamiz.

                             Eslatma!!!
Enter fullscreen mode Exit fullscreen mode

Console.ReadLine() komandasi string data tipi uchun ishlatiladi. Uni sonlar va boshqa data typelarga ishlatish uchun Console.ReadLine() ni Convert qilishimiz kerak. Misol:

Convert.To "Ishlatmoqchi bo'lgan data type nomi" (Console.ReadLine());
Enter fullscreen mode Exit fullscreen mode

Interpolation - bu qo'shtirnoq ichida o'zgaruvchilardan foydalanish imkoniyatini beradi. Buni ishlatish uchun $" " shu belgidan foydalanishimiz kerak.

                            Misollar:
Enter fullscreen mode Exit fullscreen mode

double:

   Console.Write("Biror KasrSon kirting: ");
   double KasrSon = Convert.ToDouble(Console.ReadLine());
   Console.WriteLine($"Kiritilgan KasrSon: {KasrSon}");
Enter fullscreen mode Exit fullscreen mode

Char:

   Console.Write("Biror belgi kirting: ");
   char belgi = Convert.ToChar(Console.ReadLine());
   Console.WriteLine($"Kiritilgan belgi: {belgi}");
Enter fullscreen mode Exit fullscreen mode

int:

   Console.Write("Biror bir xaqiqiy son kirting: ");
   int son = Convert.ToInt(Console.ReadLine());
   Console.WriteLine($"Kiritilgan son: {son}");
Enter fullscreen mode Exit fullscreen mode

Top comments (0)