C# 0 The Complete Reference


PART I C h a p t e r   7



Download 4,07 Mb.
Pdf ko'rish
bet225/1096
Sana23.01.2022
Hajmi4,07 Mb.
#402171
1   ...   221   222   223   224   225   226   227   228   ...   1096
Bog'liq
C-Sharp 3 The Complete Reference Herbert Schildt


PART I

C h a p t e r   7 :  

A r r a y s   a n d   S t r i n g s  

159


PART IPART I

    result = str1.CompareTo(str3);

    if(result == 0)

      Console.WriteLine("str1 and str3 are equal");

    else if(result < 0)

      Console.WriteLine("str1 is less than str3");

    else

      Console.WriteLine("str1 is greater than str3");

    Console.WriteLine();

    // Assign a new string to str2.

    str2 = "One Two Three One";

    // Search a string.

    idx = str2.IndexOf("One");

    Console.WriteLine("Index of first occurrence of One: " + idx);

    idx = str2.LastIndexOf("One");

    Console.WriteLine("Index of last occurrence of One: " + idx);

  }

}

This program generates the following output:



str1: When it comes to .NET programming, C# is #1.

Length of str1: 44

Lowercase version of str1:

    when it comes to .net programming, c# is #1.

Uppercase version of str1:

    WHEN IT COMES TO .NET PROGRAMMING, C# IS #1.

Display str1, one char at a time.

When it comes to .NET programming, C# is #1.

str1 == str2

str1 != str3

str1 is greater than str3

Index of first occurrence of One: 0

Index of last occurrence of One: 14

You can concatenate (join together) two strings using the 



+

 operator. For example, this 

statement:

string str1 = "One";

string str2 = "Two";

string str3 = "Three";

string str4 = str1 + str2 + str3;

initializes




Download 4,07 Mb.

Do'stlaringiz bilan baham:
1   ...   221   222   223   224   225   226   227   228   ...   1096




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish