C# 0 The Complete Reference



Download 4,07 Mb.
Pdf ko'rish
bet828/1096
Sana23.01.2022
Hajmi4,07 Mb.
#402171
1   ...   824   825   826   827   828   829   830   831   ...   1096
Bog'liq
C-Sharp 3 The Complete Reference Herbert Schildt

Concatenating Strings

There are two ways to concatenate (join together) two or more strings. First, you can use 

the

+

 operator, as demonstrated in Chapter 7. Second, you can use one of the various 

concatenation methods defined by 

String

. Although using 



+

 is the easiest approach in 

many cases, the concatenation methods give you an alternative.

The method that performs concatenation is called 



Concat( )

. One of its most commonly 

used forms is shown here:

public static string Concat(string 



str1

, string 



str2

)

This method returns a string that contains 



str2

 concatenated to the end of 



str1.

 Another form 

of

Concat( )

, shown here, concatenates three strings:

public static string Concat(string 

str1

, string 



str2

, string 



str3

)

In this version, a string that contains the concatenation of 



str1, str2,

 and 


str3

 is returned. 

There is also a form that concatenates four strings:

public static string Concat(string 



str1

, string 



str2

, string 



str3

, string 



str4

)

This version returns the concatenation of all four strings.



The version of 

Concat( )

 shown next concatenates an arbitrary number of strings:

public static string Concat(params string[ ] 

strs

)

Here, 



strs

 refers to a variable number of arguments that are concatenated, and the result is 

returned. Because this version of 

Concat( ) 

can be used to concatenate any number of strings, 

including two, three, or four strings, you might wonder why the other forms just shown 

www.freepdf-books.com




Download 4,07 Mb.

Do'stlaringiz bilan baham:
1   ...   824   825   826   827   828   829   830   831   ...   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