DEV Community

Firdavs Mukhsimov
Firdavs Mukhsimov

Posted on

String Operations

a) Quyidagi kod nima qiladi?

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

Javob: hamma harflarni kottadan yozib beradi;
Enter fullscreen mode Exit fullscreen mode

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)