What are explicit type conversions in C#?

CsharpProgrammingServer Side Programming

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 −

Example

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);
         Console.ReadKey();
      }
   }
}
raja
Published on 13-Aug-2018 08:58:03
Advertisements