|
이 문서는 기계로 번역한 것입니다. 원본 텍스트를 보려면 포인터를 문서의 문장 위로 올리십시오. 추가 정보
|
번역
원본
|
Convert.ToChar 메서드 (Object)
.NET Framework 4.5
네임스페이스: System
어셈블리: mscorlib(mscorlib.dll)
매개 변수
- value
- 형식: System.Object
IConvertible 인터페이스를 구현하는 개체입니다.
| 예외 | 조건 |
|---|---|
| ArgumentNullException | |
| InvalidCastException | |
| OverflowException |
object[] values = { 'r', "s", "word", (byte) 83, 77, 109324, 335812911, new DateTime(2009, 3, 10), (uint) 1934, (sbyte) -17, 169.34, 175.6m, null }; char result; foreach (object value in values) { try { result = Convert.ToChar(value); Console.WriteLine("The {0} value {1} converts to {2}.", value.GetType().Name, value, result); } catch (FormatException e) { Console.WriteLine(e.Message); } catch (InvalidCastException) { Console.WriteLine("Conversion of the {0} value {1} to a Char is not supported.", value.GetType().Name, value); } catch (OverflowException) { Console.WriteLine("The {0} value {1} is outside the range of the Char data type.", value.GetType().Name, value); } catch (NullReferenceException) { Console.WriteLine("Cannot convert a null reference to a Char."); } } // The example displays the following output: // The Char value r converts to r. // The String value s converts to s. // String must be exactly one character long. // The Byte value 83 converts to S. // The Int32 value 77 converts to M. // The Int32 value 109324 is outside the range of the Char data type. // The Int32 value 335812911 is outside the range of the Char data type. // Conversion of the DateTime value 3/10/2009 12:00:00 AM to a Char is not supported. // The UInt32 value 1934 converts to ?. // The SByte value -17 is outside the range of the Char data type. // Conversion of the Double value 169.34 to a Char is not supported. // Conversion of the Decimal value 175.6 to a Char is not supported. // Cannot convert a null reference to a Char.
Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008(서버 코어 역할은 지원되지 않음), Windows Server 2008 R2(서버 코어 역할은 SP1 이상에서 지원, Itanium은 지원되지 않음)
.NET Framework에서 모든 플랫폼의 전체 버전을 지원하지는 않습니다. 지원되는 버전의 목록을 보려면 .NET Framework 시스템 요구 사항을 참조하십시오.