C# 0 The Complete Reference


string  type also includes the  Length



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

string

 type also includes the 



Length

 property, which contains the length of the string.

To obtain the value of an individual character of a string, you simply use an index. For 

example:


string str = "test";

Console.WriteLine(str[0]);

This displays “t”, the first character of “test”. Like arrays, string indexes begin at zero. One 

important point, however, is that you cannot assign a new value to a character within a 

string using an index. An index can only be used to obtain a character.

Method


Description

static string Copy(string 



str

)

Returns a copy of 



str.

int CompareTo(string 



str

)

Returns less than zero if the invoking string is less than 



str,

 greater than zero if the invoking string is greater than 



str,

 and zero if the strings are equal.

int IndexOf(string 

str

)

Searches the invoking string for the substring specified by 



str.

 Returns the index of the first match, or –1 on failure.

int LastIndexOf(string 

str

)

Searches the invoking string for the substring specified by 



str.

 Returns the index of the last match, or –1 on failure.

string ToLower( )

Returns a lowercase version of the invoking string.

string ToUpper( )

Returns an uppercase version of the invoking string.

T

ABLE


 7-1 

Some Common String Handling Methods

www.freepdf-books.com



158

 

P a r t   I :  



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

To test two strings for equality, you can use the 




Download 4,07 Mb.

Do'stlaringiz bilan baham:
1   ...   219   220   221   222   223   224   225   226   ...   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