asilbek_ibragimov_a0c27cc

asilbek ibragimov

Posted on August 17, 2024

Formatlash
C# dasturlash tilida formatish turli usullarda amalga 
oshiriladi, Eng kop ishlatiladigan usullardan biri String 
Format va Interpolation ($ belgisi yor ishlatiladi.
Enter fullscreen mode Exit fullscreen mode

String-Format ga misol:

int yosh = 24;
double kasSon = 12.2;
string ism = "ilmhub";
string natija = String-Format ("Mening yoshim {0}, \nMen
kiritgan kasrSon: {1),\nMening ismim (2}", yosh, kasrSon, ism);

Console. WriteLine(natija);

Bu yerda {0) va (1) o'rin bosuchi (placehold) sifatida ishlatiladi, ularni is va yosh o'zgaruvchilari qiy,ati bilan to' ldiradi.

 Interpolation - $ belgisi yordamida formatlab chop etish, 
 qo'shtirnoq ichida inject(ukol) qilish, o' zgaruvchilardan 
 foydalanish.
Enter fullscreen mode Exit fullscreen mode

Console.Write("Enter the number: ");
var number = Convert. ToInt32 (Console.ReadLine());
Console.Write("Enter your name: ");
string? ism = Console.ReadLine();
Console.WriteLine($"Mening ismim: (ism). \nMen kiritgan ragam: (number}");

💖 💪 🙅 🚩
asilbek_ibragimov_a0c27cc
asilbek ibragimov

Posted on August 17, 2024

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

Sign up to receive the latest update from our blog.

Related

Formatlash
formatlash Formatlash

August 17, 2024