C# 0 The Complete Reference


object  forms of  Concat( )



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

object

 forms of 



Concat( )

 are 


very convenient because they let you avoid having to manually obtain string representations 

prior to concatenation. To see how useful these methods can be, consider the following 

program:

// Demonstrate the object form of Concat().

using System;

class MyClass {

  public static int Count = 0;

  public MyClass() { Count++; }

}

class ConcatDemo {



  static void Main() {

www.freepdf-books.com




672

 

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

    string result = String.Concat("The value is " + 19);

    Console.WriteLine("result: " + result);

    result = String.Concat("hello ", 88, " ", 20.0, " ",

                           false, " ",  23.45M);

    Console.WriteLine("result: " + result);

    MyClass mc = new MyClass();

    result = String.Concat(mc, " current count is ",

                           MyClass.Count);

    Console.WriteLine("result: " + result);

  }

}

The output is shown here:



result: The value is 19

result: hello 88 20 False 23.45

result: MyClass current count is 1

In this example, 



Concat( )

 concatenates the string representations of various types of 

data. For each argument, the 

ToString( )

 method associated with that argument is called to 

obtain a string representation. Thus, in this call to 

Concat( )

string result = String.Concat("The value is " + 19);




Download 4,07 Mb.

Do'stlaringiz bilan baham:
1   ...   827   828   829   830   831   832   833   834   ...   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