What is the difference between type conversion and type casting in C#?

Type conversion and type casting are the same in C#. It is converting one type of data to another type. In C#, type casting has two forms −

  • Implicit type conversion − These conversions are performed by C# in a type-safe manner. For example, are conversions from smaller to larger integral types and conversions from derived classes to base classes.

  • Explicit type conversion − These conversions are done explicitly by users using the pre-defined functions. Explicit conversions require a cast operator.

The following is an example showing how to cast double to int −


 Live Demo

using System;
namespace Demo {
   class Program {
      static void Main(string[] args) {
         double d = 9322.46;
         int i;

         // cast double to int
         i = (int)d;



karthikeya Boyini
karthikeya Boyini

I love programming (: That's all I know

Updated on: 20-Jun-2020


Kickstart Your Career

Get certified by completing the course

Get Started