C# Int를 Char로 변환
Harshit Jindal
2023년10월12일
Csharp
Csharp Data Type

이 자습서에서는 C#에서 int를 char로 캐스팅하는 다양한 캐스팅 방법을 살펴봅니다.
이 기사에서 C#에서 char을 int로 변환하는 방법을 확인할 수 있습니다.
명시적 유형 캐스트 Char
를 사용하여 C#
에서 Int를 Char로 캐스트
형식 이름을 입력하여 명시적 형식 캐스트는 모든 언어에서 사용되는 가장 일반적이고 널리 사용되는 방법입니다. 아래 코드는 동일한 C# 데모를 보여줍니다.
using System;
public class Program {
public static void Main() {
Console.WriteLine("(char)102 is {0}", (char)102);
}
}
출력:
(char)102 is f
위의 예에서는 C#에서 int를 char로 유형 변환하는 방법을 보여줍니다.
Convert.ToChar()
메서드를 사용하여 C#
에서 Int를 Char로 변환
C#은 char Convert.ToChar()
로의 형식 변환을 위한 명시적 메서드를 제공합니다. 형변환할 정수를 인수로 전달할 수 있으며 메서드는 해당 문자를 반환합니다.
using System;
public class Test {
public static void Main() {
int i = 65;
char c = Convert.ToChar(i);
Console.WriteLine(c);
}
}
출력:
A
튜토리얼이 마음에 드시나요? DelftStack을 구독하세요 YouTube에서 저희가 더 많은 고품질 비디오 가이드를 제작할 수 있도록 지원해주세요. 구독하다
작가: Harshit Jindal
Harshit Jindal has done his Bachelors in Computer Science Engineering(2021) from DTU. He has always been a problem solver and now turned that into his profession. Currently working at M365 Cloud Security team(Torus) on Cloud Security Services and Datacenter Buildout Automation.
LinkedIn