Skip to Content
Introducing .NET 4.0: with Visual Studio 2010
book

Introducing .NET 4.0: with Visual Studio 2010

by Alex Mackey
February 2010
Beginner content levelBeginner
400 pages
11h 13m
English
Apress
Content preview from Introducing .NET 4.0: with Visual Studio 2010

4.10. New Types

Now that the lowdown changes are out of the way, lets look at some of the new types in .NET 4.0 and modifications to existing classes and methods.

4.10.1. BigInteger

Working with really big numbers in .NET can get a bit strange. For example, try the following example (without advanced options such as overflow checking), and you might be surprised at the result you get:

int a = 2000000000;
Console.WriteLine(a * 2);
Console.ReadKey();

Surely the result is 4000000000? Running this code will give you the following answer:

−294967296

NOTE

VB.NET won't even let you compile the equivalent.

This issue occurs due to how this type of integer is represented in binary and the overflow that occurs. After the multiplication, the number gets ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

ASP.NET 3.5 For Dummies®

ASP.NET 3.5 For Dummies®

Ken Cox
ASP.NET 4 Unleashed

ASP.NET 4 Unleashed

Stephen Walther, Kevin Hoffman, Nate Dudek

Publisher Resources

ISBN: 9781430224556Purchase book