Type Conversion

Programs often need to convert values from one type to another. For example, if the user types the value 10 into a text box, the program might want to convert that string value into the number 10. Although the string value 10 is obviously a number to a human, the difference between the string 10 and the number 10 is critical to a computer program. The program cannot perform arithmetic operations, such as addition and multiplication, on the value unless it has a numeric type.

Similarly, a program cannot treat a numeric value as if it were a string. For example, it could not extract the last character in the number 1337 because 1337 is not a string. The program would first need to convert the value from a number into a string before ...

Get Start Here!™ Fundamentals of Microsoft® .NET Programming now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.