Explicit Conversion

Widening conversion - This is one in which the conversion is to a data type that can accommodate every possible value.
A widening conversion can be implicit or explicit.
Narrowing conversion - This is one in which the conversion is to a data type that does not accommodate every possible value
A narrowing conversion is always explicit.


If a conversion cannot be made without a risk of losing information, the compiler requires that you perform an explicit conversion, which is called a cast.
A cast is a way of explicitly informing the compiler that you intend to make the conversion and that you are aware that data loss might occur, or the cast may fail at run time.




System.Convert




as Operator



Object.Parse()

??

int myInt = System.Int32.Parse(mytext); 
decimal myDecimal = System.Decimal.Parse(mytext);

(Brackets)



Boxing



Unboxing



Type Checking - object.GetType()



Type Checking - is Operator



Type Checking - typeof Operator



© 2023 Better Solutions Limited. All Rights Reserved. © 2023 Better Solutions Limited TopPrevNext