Forem

Munisa Kuranbekova
Munisa Kuranbekova

Posted on

C# da input qilish

C# da input qilish C++ da input qilishga o'xshab ketadi. Masalan C++ da int son = 2; string ism = "ilmhub"; char harf ='c'; va shunga o'xshash boshqa o'zgaruvchilarni e'lon qilsak bo'ladi. C# da esa bu ozgina boshqacharoq. C# da o'zgaruvchilar ko'pincha string ko'rinishida qabul qilinadi. Shuning uchun o'zgaruvchilar e'lon qilinayotganda ularni convert qilib , ya'ni bizga kerakli holatga o'tkazib olishimiz zarur. Kod orqali tushuntiradigan bo'lsak:

using Program
{
static void Main()
{

int son= int.Parse(Console.Readline());
char belgi = char.Parse(Console.Readline());
double kasrSon = double.Parse(Console.ReadLine());
bool tekshirish = bool.Parse(Console.Readline());
}

}
Enter fullscreen mode Exit fullscreen mode

shu kodni ishga tushirib har bir o'zgaruvchiga o'zimiz uchun kerakli qiymatlarni kiritishimiz mumkin. String tioida o'zgaruvchi e'lon qilish uchun esa uni Parse qilish shart emas. Uni shundayligicha yozaversak ham bo'ladi:

string ism = Console.ReadLine();

Enter fullscreen mode Exit fullscreen mode

Image of Datadog

The Essential Toolkit for Front-end Developers

Take a user-centric approach to front-end monitoring that evolves alongside increasingly complex frameworks and single-page applications.

Get The Kit

Top comments (0)

Image of Datadog

Create and maintain end-to-end frontend tests

Learn best practices on creating frontend tests, testing on-premise apps, integrating tests into your CI/CD pipeline, and using Datadog’s testing tunnel.

Download The Guide

👋 Kindness is contagious

Explore a sea of insights with this enlightening post, highly esteemed within the nurturing DEV Community. Coders of all stripes are invited to participate and contribute to our shared knowledge.

Expressing gratitude with a simple "thank you" can make a big impact. Leave your thanks in the comments!

On DEV, exchanging ideas smooths our way and strengthens our community bonds. Found this useful? A quick note of thanks to the author can mean a lot.

Okay