Casting in C. Type conversion is used when we want to assign the value of one data type to another data type. There are two types of conversion in C#. 1) Automatic Type Conversion / Implicit Type Conversion 2) Explicit Type Conversion
If the data types are of the same type (e.g. numeric) then the C# compiler does automatic type conversion. OR when we assign a smaller data type value to bigger data type value C# does automatic type conversion. In C# numeric data types are compatible with each other so in these data type automatic conversion is possible, but when we try to assign a numeric data type to a string type then it is a compile time error. Because these are not the same. For example, when we assign a Boolean type to a char type then again it’s a compile time error. C# does not support automatic

Type Conversion & Casting

Type Conversion & Casting Type conversion is used when we want to assign the value of one data type to another data type. There are two types of conversion in…

Continue Reading Type Conversion & Casting