C# Type Conversion
C# is a strongly typed language, which means that all variables have a type that must be declared, and
that the compiler verifies the type-consistency of expressions. Expressions, of course, are always of a
type built-in to the C# language, or are user-defined types.
For programmers coming to C# from a weakly typed language such as Visual Basic 6, strong typing and the
programmatic type conversions that it mandates are one of the most difficult things about working in C#.
But cheer up: working with type conversion is not brain surgery! After reading the two parts of this
article, you should be able to zip through most issues involving C# type conversion.
The first part of this article explains strong typing and its rationale, shows how VB6 differs from VB.NET differs from C#.NET , describes the various possible type conversion techniques, and explains implicit conversion (also called implicit casting.) In the second part of the article, I’ll show you how explicit conversion, or
casting, works. I’ll also discuss the as operator, the conversion methods that are members of the System.Convert
class, and the ToString method.
|
|
Search Engine Optimization
 
Syndication Viewer
Our Web host:
IX WebHosting
|