C# 0 The Complete Reference


Splitting and Joining Strings



Download 4,07 Mb.
Pdf ko'rish
bet838/1096
Sana23.01.2022
Hajmi4,07 Mb.
#402171
1   ...   834   835   836   837   838   839   840   841   ...   1096
Bog'liq
C-Sharp 3 The Complete Reference Herbert Schildt

Splitting and Joining Strings

Two fundamental string-handling operations are split and join. A 



split

 decomposes a string 

into its constituent parts. A 

join

 constructs a string from a set of parts. To split a string, 



String

 defines 



Split( )

. To join a set of strings, 



String

 provides 



Join( )

.

There are several versions of 



Split( )

. Two commonly used forms, which have been 

available since C# 1.0, are shown here:

public string[ ] Split(params char[ ] 



seps

)

public string[ ] Split(params char[ ] 



seps

, int 


count

)

www.freepdf-books.com




678

 

P a r t   I I :  



E x p l o r i n g   t h e   C #   L i b r a r y

The first form splits the invoking string into pieces and returns an array containing the 

substrings. The characters that delimit each substring are passed in 

seps.

 If 


seps

 is null or 

refers to an empty string, then whitespace is used as the separator. In the second form, no 

more than 



count

 substrings will be returned.

The two forms of the 

Join( )

 method are shown here:

public static string Join(string 

sep

, string[ ] 



strs

)

public static string Join(string 



sep

, string[ ] 



strs

, int 


start

, int 


count

)

The first form returns a string that contains the concatenation of the strings in 



strs.

 The 


second form returns a string that contains the concatenation of 

count

 strings in 



strs,

beginning at 



strs

[

start

]. For both versions, each string is separated from the next by the 

string specified by 



sep.

The following program demonstrates 




Download 4,07 Mb.

Do'stlaringiz bilan baham:
1   ...   834   835   836   837   838   839   840   841   ...   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