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

AWS Security LIVE!

Join us for AWS Security LIVE!

Discover the future of cloud security. Tune in live for trends, tips, and solutions from AWS and AWS Partners.

Learn More

Top comments (0)

The Most Contextual AI Development Assistant

Pieces.app image

Our centralized storage agent works on-device, unifying various developer tools to proactively capture and enrich useful materials, streamline collaboration, and solve complex problems through a contextual understanding of your unique workflow.

πŸ‘₯ Ideal for solo developers, teams, and cross-company projects

Learn more