Decimal.GetTypeCode() Method in C# with Examples


The Decimal.GetTypeCode() method in C# is used to returns the TypeCode for value type Decimal.

Syntax

Following is the syntax −

public TypeCode GetTypeCode ();

Example

Let us now see an example to implement the Decimal.GetTypeCode() method −

using System;
public class Demo {
   public static void Main(){
      Decimal val = Decimal.MaxValue;
      Console.WriteLine("Decimal Value = {0}", val);
      Console.WriteLine("HashCode = {0}", (val.GetHashCode()) );
      TypeCode type = val.GetTypeCode();
      Console.WriteLine("TypeCode = "+type);
   }
}

Output

This will produce the following output −

Decimal Value = 79228162514264337593543950335
HashCode = 1173356544
TypeCode = Decimal

Example

Let us now see another example to implement the Decimal.GetTypeCode() method −

using System;
public class Demo {
   public static void Main(){
      Decimal val = 3972.491M;
      Console.WriteLine("Decimal Value = {0}", val);
      Console.WriteLine("HashCode = {0}", (val.GetHashCode()) );
      TypeCode type = val.GetTypeCode();
      Console.WriteLine("TypeCode = "+type);
   }
}

Output

This will produce the following output −

Decimal Value = 3972.491
HashCode = 620041307
TypeCode = Decimal

Updated on: 12-Nov-2019

38 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements