mushtariy

Mushtariy

Posted on August 9, 2024

Input

"Console.ReadLine()" - input qilish uchun kerak.

"Console.ReadLine()" - faqat stringga ishlaydi.

int, double, float, char lar bilan input ishlatish uchun.int a = Convert.ToInt32(Console.ReadLine());

Convert.To.va data type yoziladi.

Interpolation - bu qo'shtirnoq ichida o'zgaruvchilardan foydalanish imkoniyatini beradi.

$" " - oldindan bu belgini foydalanish kerak

Double ga misol:

Console.Write("Biror bir xaqiqiy son kiirting: ");
double kasrSon = Convert.ToDouble(Console.ReadLine());
Console.WriteLine($"Kiritilgan kasrSon: {kasrSon}");
Enter fullscreen mode Exit fullscreen mode

Char ga misol:

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

Misol:

class Program
{
    static void Main()
    {
        Console.Write("Mashinangiz bormi? (ha/yo'q): ");
        string javob = Console.ReadLine().ToLower();
        bool mashinaBor = javob == "ha";

        if (mashinaBor)
        {
            Console.WriteLine("Sizning mashinangiz bor.");
        }
        else
        {
            Console.WriteLine("Sizning mashinangiz yo'q.");
        }
    }
}
Enter fullscreen mode Exit fullscreen mode
💖 💪 🙅 🚩
mushtariy
Mushtariy

Posted on August 9, 2024

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related

String methods
programming String methods

August 24, 2024

Formatlash
programming Formatlash

August 17, 2024

Input
programming Input

August 9, 2024