---
title: "What is the difference between Type Conversion and Type Casting?"  
description: "What is the difference between Type Conversion and Type Casting?"  
author: "Hemant Patel"  
published: 2017-03-02  
updated: 2020-09-24  
canonical: https://www.mindstick.com/interview/23215/what-is-the-difference-between-type-conversion-and-type-casting  
category: "c#"  
tags: ["c#"]  
reading_time: 2 minutes  

---

# What is the difference between Type Conversion and Type Casting?

Type conversion is done automatically by the compiler. When both data types are compatible then type conversion done by the compiler. Type conversion done explicitly while compiling. It’s widening conversion type. In type conversion destination type must be larger than source type. For Example:-

```
         int x=3;                   float y;                   y=x; // value in y=3.000  
```

But Type Casting is to be “explicitly done” by the programmer. It’s also applied to two ‘incompatible’ data types. Type casting required a casting operator. Destination type must be smaller than the source type in Type Casting.

For Example:-

```
        int x;                  byte y;                  y=(byte)x;
```

## Answers

### Answer by Hemant Patel

Type conversion is done automatically by the compiler. When both data types are compatible then type conversion done by the compiler. Type conversion done explicitly while compiling. It’s widening conversion type. In type conversion destination type must be larger than source type. For Example:-

```
         int x=3;                   float y;                   y=x; // value in y=3.000  
```

But Type Casting is to be “explicitly done” by the programmer. It’s also applied to two ‘incompatible’ data types. Type casting required a casting operator. Destination type must be smaller than the source type in Type Casting.

For Example:-

```
        int x;                  byte y;                  y=(byte)x;
```


---

Original Source: https://www.mindstick.com/interview/23215/what-is-the-difference-between-type-conversion-and-type-casting

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
