Input
Mushtariy
Posted on August 9, 2024
"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}");
Char ga misol:
Console.Write("Biror bir belgi kiirting: ");
char belgi = Convert.ToChar(Console.ReadLine());
Console.WriteLine($"Kiritilgan belgi: {belgi}");
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.");
}
}
}
💖 💪 🙅 🚩
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
programming Mastering C# Fundamentals: A Beginner’s Journey into .NET Development
September 19, 2024