C# 0 The Complete Reference



Download 4,07 Mb.
Pdf ko'rish
bet821/1096
Sana23.01.2022
Hajmi4,07 Mb.
#402171
1   ...   817   818   819   820   821   822   823   824   ...   1096
Bog'liq
C-Sharp 3 The Complete Reference Herbert Schildt

StringBuilder

, which is in 

the

System.Text

 namespace. For most purposes, however, you will want to use 



string

, not 


StringBuilder

.

663



CHAPTER

www.freepdf-books.com




664

 

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 String Class

String

 is defined in the 



System

 namespace. It implements the 



IComparable

,

IComparable

,

ICloneable

,

IConvertible

,

IEnumerable

,

IEnumerable

,

and


IEquatable

 interfaces. 



String

 is a sealed class, which means that it cannot be 

inherited.

String

 provides string-handling functionality for C#. It underlies C#’s built-in 



string

 type and is part of the .NET Framework. The next few sections examine 



String

in detail.



The String Constructors

The


String

 class defines several constructors that allow you to construct a string in a variety 

of ways. To create a string from a character array, use one of these constructors:

public String(char[ ] 



chrs

)

public String(char[ ] 



chrs

, int 


start

, int 


count

)

The first form constructs a string that contains the characters in 



chrs.

 The second form uses 



count

 characters from 



chrs,

 beginning at the index specified by 



start.

You can create a string that contains a specific character repeated a number of times 

using this constructor:

public String(char 



ch

, int 


count

)

Here, 



ch

 specifies the character that will be repeated 



count

 times.


You can construct a string given a pointer to a character array using one of these 

constructors:

public String(char* 

chrs

)

public String(char* 



chrs

, int 


start

, int 


count

)

The first form constructs a string that contains the characters pointed to by 



chrs.

 It is assumed 

that

chrs

 points to a null-terminated array, which is used in its entirety. The second form uses 



count

 characters from the array pointed to by 



chrs,

 beginning at the index specified by 



start.

Because they use pointers, these constructors can be used only in unsafe code.

You can construct a string given a pointer to an array of bytes using one of these 

constructors:

public String(sbyte* 

chrs

)

public String(sbyte* 



chrs

, int 


start

, int 


count

)

public String(sbyte* 



chrs

, int 


start

, int 


count

, Encoding 



en

)

The first form constructs a string that contains the bytes pointed to by 



chrs.

 It is assumed 

that

chrs

 points to a null-terminated array, which is used in its entirety. The second form 

uses

count

 characters from the array pointed to by 



chrs,

 beginning at the index specified by 



start.

 The third form lets you specify how the bytes are encoded. The default encoding is 



ASCIIEncoding

. The 


Encoding

 class is in the 



System.Text

 namespace. Because they use 

pointers, these constructors can be used only in unsafe code.

www.freepdf-books.com




Download 4,07 Mb.

Do'stlaringiz bilan baham:
1   ...   817   818   819   820   821   822   823   824   ...   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