DEV Community

asilbek ibragimov
asilbek ibragimov

Posted on

1 1 1 1 1

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}");

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay