Implicit conversion from Char to Decimal in C#

CsharpProgrammingServer Side Programming

To implicitly convert char to a Decimal, firstly set a char.

char c = 'p';

To convert char to decimal, assign the value.

decimal dec;
dec = c;

Let us see the above example.

Example

 Live Demo

using System;
public class Demo {
   public static void Main() {
      char c = 'p';
      decimal dec;
      Console.WriteLine("Implicit conversion from Char to Decimal");
      dec = c;
      Console.WriteLine("Decimal : "+dec);
   }
}

Output

Implicit conversion from Char to Decimal
Decimal : 112
raja
Published on 12-Sep-2018 09:27:34
Advertisements