DEV Community

Sanjar Rashidov
Sanjar Rashidov

Posted on

2 1 1 1 1

C# input

C# dasturlash tilida uchun Console.ReadLine() buyrug'i orqali foydalanuvchidan ma'lumot qabul qilish mumkin va bu buyruq faqat string tipiga mansub.

Agar biz butun, kasr son yoki char qabul qilmoqchi bo'lsak Convert yoki Parse qilishimiz kerak bo'ladi.

Masalan:

class Program
{
    static void Main(string[] args)
    {
        Console.Write("Ismingizni kiriting: ");
        string name = Console.ReadLine();
        Console.WriteLine("Foydalanuvchining ismi " + name);

        // String dan int ga Convert qilishni birinchi usuli
        Console.Write("1-sonni kiriting: ");
        int s1 = Convert.ToInt32(Console.ReadLine());
        Console.Write("2-sonni kiriting: ");
        int s2 = Convert.ToInt32(Console.ReadLine());
        int result1 = son1 + son2;
        Console.WriteLine("Yig'indi: " + result1);

        // String dan int ga Convert qilishni ikkinchi usul
        Console.Write("1-sonni kiriting: ");
        int n1 = int.Parse(Console.ReadLine());
        Console.Write("2-sonni kiriting:  ");
        int n2 = int.Parse(Console.ReadLine());
        int result2 = n1 + n2;
        Console.WriteLine("Yig'indi: " + result2);
    }
}
Enter fullscreen mode Exit fullscreen mode

Image of Datadog

The Future of AI, LLMs, and Observability on Google Cloud

Datadog sat down with Google’s Director of AI to discuss the current and future states of AI, ML, and LLMs on Google Cloud. Discover 7 key insights for technical leaders, covering everything from upskilling teams to observability best practices

Learn More

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