Braintique.com header
Left Navigation Bar

Implicit Conversion

The available implicit built-in type conversions in C# are shown in the table below.

Type (Conversion From)

Legal Implicit Conversion To

sbyte

short, int, long, float, double, or decimal

byte

short, ushort, int, uint, long, ulong, float, double, or decimal

short

int, long, float, double, or decimal

ushort

int, uint, long, ulong, float, double, or decimal

int

long, float, double, or decimal

uint

long, ulong, float, double, or decimal

long

float, double, or decimal

char

ushort, int, uint, long, ulong, float, double, or decimal

float

double

ulong

float, double, or decimal

The following implicit conversions are never legal:

  • There are no allowable implicit conversions from bool, double, or decimal types;

  • There are no implicit conversions allowed to the char type;

  • There are no implicit conversions allowed between the floating-point types and the decimal type.

Implicit conversions are also possible for more complex reference types. Generally, when you eyeball two reference types to see whether you can do an implicit conversion, you should be asking the question as with simple type conversions: Can I guarantee the success of the operation without data loss?

In addition, some rules do apply to reference-type implicit conversions. For example, any reference type can be implicitly converted to object. And, any derived class can be implicitly converted to the class it was derived from.

It’s time to turn to explicit conversion

.

Previous Table of Contents Next


Google
 
Web www.braintique.com
www.digitalfieldguide.com www.googleplexblog.com


Home | Barticles | Blogs | Books | Services | FAQ | Contact

© Braintique.com. All rights reserved.

Search Engine Optimization







RSS 2.0 Syndication feed

Syndication Viewer

Our Web host:
IX WebHosting



Food for Your Brain! Get a Barticle! Questions Answered Books for You What We Can Do For You Contact Us Brain Food Questions Answered Books for You What We Can Do For You Frequently Asked Questions About Us Google Research Photoshop Wi-Fi and Wireless Networking The Natural Way to Write