UInt64.ToString() Method in C# with Examples


The UInt64.ToString() method in C# is used to convert the numeric value of the current UInt64 instance to its equivalent string representation.

Syntax

Following is the syntax −

public override string ToString();

Example

Let us now see an example to implement the UInt64.ToString() method −

using System;
public class Demo {
   public static void Main(){
      ulong val1 = 465656665;
      ulong val2 = 232525678;
      Console.WriteLine("Value1 (String representation) = "+val1.ToString());
      Console.WriteLine("Value2 (String representation) = "+val2.ToString());
      bool res = val1.Equals(val2);
      Console.WriteLine("Return value (comparison) = "+res);
      if (res)
         Console.WriteLine("val1 = val2");
      else
         Console.WriteLine("val1 != val2");
   }
}

Output

This will produce the following output −

Value1 (String representation) = 465656665
Value2 (String representation) = 232525678
Return value (comparison) = False
val1 != val2

Example

Let us now see another example to implement the UInt64.ToString() method −

using System;
public class Demo {
   public static void Main(){
      ulong val1 = 0;
      ulong val2 = UInt64.MaxValue;
      Console.WriteLine("Value1 (String representation) = "+val1.ToString());
      Console.WriteLine("Value2 (String representation) = "+val2.ToString());
      bool res = val1.Equals(val2);
      Console.WriteLine("Return value (comparison) = "+res);
      if (res)
         Console.WriteLine("val1 = val2");
      else
         Console.WriteLine("val1 != val2");
   }
}

Output

This will produce the following output −

Value1 (String representation) = 0
Value2 (String representation) = 18446744073709551615
Return value (comparison) = False
val1 != val2

Updated on: 13-Nov-2019

311 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements