DEV Community

asilbek ibragimov
asilbek ibragimov

Posted on

10. String operations

10. String operations

a)Quyidagi kod nima qiladi?

string name = "John" ;
string upperName = name. ToUpper ();
Console. WriteLine (upperName);

Enter fullscreen mode Exit fullscreen mode

b)Stringlarni birlashtirishning bir usulini keltiring.

c)Stringlarni solishtirish uchun qaysi metod ishlatiladi?

Javoblari:


a) Tekstdagi hamma harflarni kottadan yozib beradi;
Enter fullscreen mode Exit fullscreen mode
b) Replace() metodi orqali ma'lum bir qatorni boshqa qiymatga almashtirish mumkin.
using System;
using System.Text;
Enter fullscreen mode Exit fullscreen mode

c)

class Program
{
    static void Main()
    {
        StringBuilder sb = new StringBuilder("Hello Beautiful World!");
Enter fullscreen mode Exit fullscreen mode
    sb.Remove(6, 10);
    Console.WriteLine(sb.ToString()); 
}
Enter fullscreen mode Exit fullscreen mode

}

c) 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)