Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

6. Framework Fundamentals > Working with Numbers

Working with Numbers

Conversions

We covered numeric conversions in previous chapters and sections; Table 6-7 summarizes all the options.

Table 6-7. Summary of numeric conversions

Task

Functions

Examples

Parsing base 10 numbers

Parse

TryParse

double d = double.Parse ("3.5");

int i;

bool ok = int.TryParse ("3", out i);

Parsing from base 2, 8, or 16

Convert.ToIntegral

int i = Convert.ToInt32 ("1E", 16);

Formatting to hexadecimal

ToString ("X")

string hex = 45.ToString ("X");

Lossless numeric conversion

Implicit cast

int i = 23;

double d = d;

Truncating numeric conversion

Explicit cast


  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint