DEV Community

Sunnat Qayumov
Sunnat Qayumov

Posted on

10. String operations

a)Quyidagi kod nima qiladi?

string name = "John" ;
string upperName = name. ToUpper ();
Console. WriteLine (upperName);
Enter fullscreen mode Exit fullscreen mode

Javob: hamma harflarni kottadan yozib beradi;

b)Stringlarni birlashtirishning bir usulini keltiring.

Replace() metodi orqali ma'lum bir qatorni boshqa qiymatga almashtirish mumkin.
using System;
using System.Text;

class Program
{
    static void Main()
    {
        StringBuilder sb = new StringBuilder("Hello Beautiful World!");

        sb.Remove(6, 10);
        Console.WriteLine(sb.ToString()); 
    }
}
Enter fullscreen mode Exit fullscreen mode

c)Stringlarni solishtirish uchun qaysi metod ishlatiladi?

Agar siz stringlarning ma'lum bir tartibda
(masalan, katta-kichik harflarga qarab) 
solishtirishni xohlasangiz, compareTo() metodidan 
foydalanishingiz mumkin.
Enter fullscreen mode Exit fullscreen mode

Top comments (0)