DEV Community

umida5
umida5

Posted on

String operations

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

bu kodda name degan ozgaruvchini qiymatini ToUpper funkiyasi bilan hamma
harflarini katta qilib beradi.
natija: "JOHN";

1.String qiymatlarini birlashtirish uchun + operatoridan foydalanish mumkin. Bu string larni qo'shish imkonini beradi.
Shuningdek, String.Concat() metodidan ham foydalanishingiz mumkin.


string name = "Ali";
string surname = "Valiyev";
string fullName = name + " " + surname;
// Yoki
string fullNameConcat = String.Concat(name, " ", surname);
Enter fullscreen mode Exit fullscreen mode
  1. Compare: Compare metodi ikkita string ni taqqoslaydi va ularning tartibini aniqlash uchun ishlatiladi:
  2. 0 qaytarsa, ikkisi teng.
  3. Katta son qaytsa, birinchi string kattaroq.
  4. Manfiy son qaytsa, birinchi string kichikroq.

string str1 = "Apple";
string str2 = "Banana";
int result = string.Compare(str1, str2);
Console.WriteLine(result);  // -1 (Apple kichik Banana'dan)
Enter fullscreen mode Exit fullscreen mode

Image of Datadog

The Essential Toolkit for Front-end Developers

Take a user-centric approach to front-end monitoring that evolves alongside increasingly complex frameworks and single-page applications.

Get The Kit

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