Int64.GetTypeCode Method in C# with Examples

CsharpServer Side ProgrammingProgramming

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

Syntax

Following is the syntax −

public TypeCode GetTypeCode ();

Example

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

using System;
public class Demo {
   public static void Main(){
      long val1 = 0;
      long val2 = Int64.MaxValue;
      Console.WriteLine("Value1 = "+val1);
      Console.WriteLine("Value2 = "+val2);
      Console.WriteLine("Are they equal? = "+val1.Equals(val2));
      Console.WriteLine("Value1 (HashCode) = "+val1.GetHashCode());
      Console.WriteLine("Value2 (HashCode) = "+val2.GetHashCode());
      TypeCode type1 = val1.GetTypeCode();
      TypeCode type2 = val2.GetTypeCode();
      Console.WriteLine("TypeCode for val1 = "+val1.GetTypeCode());
      Console.WriteLine("TypeCode for val2 = = "+val1.GetTypeCode());
   }
}

Output

This will produce the following output −

Value1 = 0
Value2 = 9223372036854775807
Are they equal? = False
Value1 (HashCode) = 0
Value2 (HashCode) = -2147483648
TypeCode for val1 = Int64
TypeCode for val2 = = Int64

Example

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

using System;
public class Demo {
   public static void Main(){
      long val1 = 8768768766;
      long val2 = Int64.MaxValue;
      Console.WriteLine("Value1 = "+val1);
      Console.WriteLine("Value2 = "+val2);
      Console.WriteLine("Are they equal? = "+val1.Equals(val2));
      Console.WriteLine("Value1 (HashCode) = "+val1.GetHashCode());
      Console.WriteLine("Value2 (HashCode) = "+val2.GetHashCode());
      TypeCode type1 = val1.GetTypeCode();
      TypeCode type2 = val2.GetTypeCode();
      Console.WriteLine("TypeCode for val1 = "+val1.GetTypeCode());
      Console.WriteLine("TypeCode for val2 = = "+val1.GetTypeCode());
   }
}

Output

This will produce the following output −

Value1 = 8768768766
Value2 = 9223372036854775807
Are they equal? = False
Value1 (HashCode) = 178834172
Value2 (HashCode) = -2147483648
TypeCode for val1 = Int64
TypeCode for val2 = = Int64
raja
Published on 13-Nov-2019 10:44:28
Advertisements