C# 0 The Complete Reference


string  method called  ToCharArray( )



Download 4,07 Mb.
Pdf ko'rish
bet709/1096
Sana23.01.2022
Hajmi4,07 Mb.
#402171
1   ...   705   706   707   708   709   710   711   712   ...   1096
Bog'liq
C-Sharp 3 The Complete Reference Herbert Schildt

string

 method called 



ToCharArray( )

, which 


returns an array containing the characters in the string. The result is assigned to a variable 

called


chrArray

, which is then used by a nested 



from

 clause to obtain the individual characters 

in the array. The query then sorts the characters and returns the resulting sequence.

// Use a let clause and a nested from clause.

using System;

using System.Linq;

class LetDemo {

  static void Main() {

    string[] strs = { "alpha", "beta", "gamma" };

    // Create a query that obtains the characters in the

    // strings, returned in sorted order. Notice the use

    // of a nested from clause.

    var chrs = from str in strs

               let chrArray = str.ToCharArray()

                  from ch in chrArray

                  orderby ch

                  select ch;

    Console.WriteLine("The individual characters in sorted order:");

    // Execute the query and display the results.

    foreach(char c in chrs) Console.Write(c + " ");

    Console.WriteLine();

  }


}

The output is shown here:

The individual characters in sorted order:

a a a a a b e g h l m m p t

www.freepdf-books.com



566

 

P a r t   I :  



T h e   C #   L a n g u a g e

In the program, notice how the 




Download 4,07 Mb.

Do'stlaringiz bilan baham:
1   ...   705   706   707   708   709   710   711   712   ...   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