Type Safety, Implicit Conversion, and Explicit Conversion

Type Safety and Conversion- by Sagar Jaybhay

Type Safety: – Type safety means preventing type errors. What does it mean?

You can not directly move data from one data type to another data type. When one type of data type assigned to another data type and language compiler doesn’t throw an error like javascript which means it does not type safe language but in c# when you assigned a string value to integer type variable it throws an error at compile time. Use of type-safe language is it not allows you or it prompt you at compile time only.

Implicit Conversion: – When you move one data type to another data type without any data loss then it’s called Implicit Conversion.

For Ex. Int i=10; double b=i;

it is possible because no data loss happened. It’s called Implicit Conversion.

Explicit Conversion: – When you cast bigger data type to small data type and there might be chances of data loss, so you need to specify from which data type to which data type you need to convert explicitly that’s why its called explicit casting. And for implicit casting, there is no need to specify a data type for casting so it’s called implicit casting. For explicit casting .net alerts a developer there may be a chance of data loss.

Conversion: –  When you convert from one data type to another data type using convert class it’s conversion.

. String val=”4”; int i=Convert.ToInt32(val);

Parsing Video

Sagar Jaybhay, from Maharashtra, India, is currently a Senior Software Developer at Software Company. He has continuously grown in the roles that he has held in the more than seven years he has been with this company. Sagar Jaybhay is an excellent team member and prides himself on his work contributions to his team and company as a whole.

Sagar Jaybhay

Sagar Jaybhay, from Maharashtra, India, is currently a Senior Software Developer at Software Company. He has continuously grown in the roles that he has held in the more than seven years he has been with this company. Sagar Jaybhay is an excellent team member and prides himself on his work contributions to his team and company as a whole.

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *