C# 0 The Complete Reference


PART II C h a p t e r   2 1



Download 4,07 Mb.
Pdf ko'rish
bet810/1096
Sana23.01.2022
Hajmi4,07 Mb.
#402171
1   ...   806   807   808   809   810   811   812   813   ...   1096
Bog'liq
C-Sharp 3 The Complete Reference Herbert Schildt


PART II

C h a p t e r   2 1 :  

E x p l o r i n g   t h e   S y s t e m   N a m e s p a c e    

655


Method

Meaning


public static long

    DoubleToInt64Bits(double 



v

)

Conver ts 



v

 into a 


long

 integer and returns the 

result.

public static byte[ ] GetBytes(bool 



v

)

Conver ts 



v

 into a 1-byte array and returns the 

result.

public static byte[ ] GetBytes(char 



v

)

Conver ts 



v

 into a 2-byte array and returns the 

result.

public static byte[ ] GetBytes(double 



v

)

Conver ts 



v

 into an 8-byte array and returns the 

result.

public static byte[ ] GetBytes(float 



v

)

Conver ts 



v

 into a 4-byte array and returns the 

result.

public static byte[ ] GetBytes(int 



v

)

Conver ts 



v

 into a 4-byte array and returns the 

result.

public static byte[ ] GetBytes(long 



v

)

Conver ts 



v

 into an 8-byte array and returns the 

result.

public static byte[ ] GetBytes(shor t 



v

)

Conver ts 



v

 into a 2-byte array and returns the 

result.

public static byte[ ] GetBytes(uint 



v

)

Conver ts 



v

 into a 4-byte array and returns the 

result.

public static byte[ ] GetBytes(ulong 



v

)

Conver ts 



v

 into an 8-byte array and returns the 

result.

public static byte[ ] GetBytes(ushor t 



v

)

Conver ts 



v

 into a 2-byte array and returns the 

result.

public static double

    Int64BitsToDouble(long 

v

)

Conver ts 



v

 into a 


double

 value and returns the 

result.

public static bool ToBoolean(byte[ ] 



a

, int 


idx

)

Converts the byte at 



a

[

idx

] into its 

bool


 equivalent 

and returns the result. A non-zero value is 

converted to true; zero is converted to false.

public static char ToChar(byte[ ] 



a

, int 


star t

)

Conver ts two bytes star ting at 



a

[

star t

] into its 

char


 equivalent and returns the result.

public static double ToDouble(byte[ ] 



a

,

                                            int 



star t

)

Conver ts eight bytes star ting at 



a

[

star t

] into its 

double


 equivalent and returns the result.

public static shor t ToInt16(byte[ ] 



a

, int 


star t

)

Conver ts two bytes star ting at 



a

[

star t

] into its 

short


 equivalent and returns the result.

public static int ToInt32(byte[ ] 



a

, int 


star t

)

Conver ts four bytes star ting at 



a

[

star t

] into its 

int


 equivalent and returns the result.

public static long ToInt64(byte[ ] 



a

, int 


star t

)

Conver ts eight bytes star ting at 



a

[

star t

] into its 

long


 equivalent and returns the result.

public static float ToSingle(byte[ ] 



a

, int 


star t

)

Conver ts four bytes star ting at 



a

[

star t

] into its 

float


 equivalent and returns the result.

T

ABLE



 21-13 

Methods Defi ned by 

BitConverter

www.freepdf-books.com




656

 

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

Random_Numbers_with_Random'>Generating Random Numbers with Random

To generate a sequence of pseudorandom numbers, you will use the 



Random

 class. 


Sequences of random numbers are useful in a variety of situations, including simulations 

and modeling. The starting point of the sequence is determined by a 



seed

 value, which can 

be automatically provided by 

Random

 or explicitly specified.



Random

 defines these two constructors:

public Random( )

public Random(int 



seed

)

The first version creates a 



Random

 object that uses the system time to compute the seed 

value. The second uses the value of 

seed

 as the seed value.



Random

 defines the methods shown in Table 21-14.

Here is a program that demonstrates 

Random

 by creating a pair of computerized dice:

// An automated pair of dice.

using System;

class RandDice {

  static void Main() {

    Random ran = new Random();

    Console.Write(ran.Next(1, 7) + " ");

    Console.WriteLine(ran.Next(1, 7));

  }


}

public static string ToString(byte[ ] 



a

)

Conver ts the bytes in 



a

 into a string. The string 

contains the hexadecimal values associated 

with the bytes, separated by hyphens.

public static string ToString(byte[ ] 

a

, int 


star t

)

Conver ts the bytes in 



a,

 beginning at 



a

[

star t

], into a string. The string contains the 

hexadecimal values associated with the bytes, 

separated by hyphens.

public static string ToString(byte[ ] 



a

, int 


star t

,

                                        int 



count

)

Converts the bytes in 



a,

 beginning at 



a

[

start

] and 

running for 



count

 bytes, into a string. The string 

contains the hexadecimal values associated with 

the bytes, separated by hyphens.

public static ushor t ToUInt16(byte[ ] 

a

, int 


star t

)

Conver ts two bytes star ting at 



a

[

star t

] into its 

ushort


 equivalent and returns the result.

public static uint ToUInt32(byte[ ] 



a

, int 


star t

)

Conver ts four bytes star ting at 



a

[

star t

] into its 

uint


 equivalent and returns the result.

public static ulong ToUInt64(byte[ ] 



a

, int 


star t

)

Conver ts eight bytes star ting at 



a

[

star t

] into its 

ulong


 equivalent and returns the result.

T

ABLE



 21-13 

Methods Defi ned by 

BitConverter 

(continued)

Method


Meaning

www.freepdf-books.com




Download 4,07 Mb.

Do'stlaringiz bilan baham:
1   ...   806   807   808   809   810   811   812   813   ...   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