DEV Community

Zahro
Zahro

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

Natija: JOHN

b) Stringlarni birlashtirishning bir usulini keltiring.

string firstName = "John";
string lastName = "Doe";
string fullName = firstName + " " + lastName;
Enter fullscreen mode Exit fullscreen mode

c) Stringlarni solishtirish uchun string.Compare() yoki Equals() metodi ishlatiladi.

string str1 = "Apple";
string str2 = "Banana";
int result = string.Compare(str1, str2);
Console.WriteLine(result);
Enter fullscreen mode Exit fullscreen mode

Natija: -1 (Apple kichik Banana'dan)

Top comments (0)