What are explicit type conversions in C#?

Explicit conversions require a cast operator.

These conversions are done explicitly by users using the pre-defined functions.

Let us see an example to cast double to int −


using System;

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

         Console.WriteLine("double: "+d);

         i = (int)d;
         Console.WriteLine("int: "+i);
karthikeya Boyini
karthikeya Boyini

I love programming (: That's all I know