Computer >> 컴퓨터 >  >> 프로그램 작성 >> C#

예제가 있는 C#의 UInt64.ToString() 메서드

<시간/>

C#의 UInt64.ToString() 메서드는 현재 UInt64 인스턴스의 숫자 값을 해당하는 문자열 표현으로 변환하는 데 사용됩니다.

구문

다음은 구문입니다 -

public override string ToString();

예시

이제 UInt64.ToString() 메서드를 구현하는 예를 살펴보겠습니다. -

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");
   }
}

출력

이것은 다음과 같은 출력을 생성합니다 -

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

예시

이제 UInt64.ToString() 메서드를 구현하는 또 다른 예를 살펴보겠습니다. -

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");
   }
}

출력

이것은 다음과 같은 출력을 생성합니다 -

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