Languages Features Calendar CSV Lists Blog About Sponsor Add Language
GitHub icon

Type Casting

Type Casting

Type Casting is a feature.

Changing an expression from one data type to another.

Languages with Type Casting include C, MATLAB, C#, TypeScript, Jule

Example from C:
double da = 3.3; double db = 3.3; double dc = 3.4; int result = (int)da + (int)db + (int)dc; //result == 9
Example from MATLAB:
b = cast(a, 'like', p)
Example from C#:
Animal animal = new Cat(); Bulldog b = (Bulldog) animal; // if (animal is Bulldog), stat.type(animal) is Bulldog, else an exception b = animal as Bulldog; // if (animal is Bulldog), b = (Bulldog) animal, else b = null animal = null; b = animal as Bulldog; // b == null
Example from TypeScript:
Example from Jule:
let x = (int)(3.14)
triple-feature.html 路 type-casting-feature.html 路 type-parameters-feature.html

View source

PLDB - Build the next great programming language 路 v2022 Day 33 Docs Build Acknowledgements Traffic Today Traffic Trends Mirrors GitHub