TypeCode 열거형
정의
개체의 형식을 지정합니다.Specifies the type of an object.
public enum class TypeCode
public enum TypeCode
[System.Serializable]
public enum TypeCode
[System.Serializable]
[System.Runtime.InteropServices.ComVisible(true)]
public enum TypeCode
type TypeCode =
[<System.Serializable>]
type TypeCode =
[<System.Serializable>]
[<System.Runtime.InteropServices.ComVisible(true)>]
type TypeCode =
Public Enum TypeCode
- 상속
- 특성
필드
Boolean | 3 |
|
Byte | 6 | 0과 255 사이의 값을 가진 부호 없는 8비트 정수를 나타내는 정수 계열 형식입니다.An integral type representing unsigned 8-bit integers with values between 0 and 255. |
Char | 4 | 0과 65535 사이의 값을 가진 부호 없는 16비트 정수를 나타내는 정수 계열 형식입니다.An integral type representing unsigned 16-bit integers with values between 0 and 65535. Char 형식에 사용할 수 있는 값 집합은 유니코드 문자 집합과 일치합니다.The set of possible values for the Char type corresponds to the Unicode character set. |
DateTime | 16 | 날짜 및 시간 값을 나타내는 형식입니다.A type representing a date and time value. |
DBNull | 2 | 데이터베이스 Null(열) 값입니다.A database null (column) value. |
Decimal | 15 | 1.0 x 10 -28부터 약 7.9 x 10 28까지 28~29개의 유효 자릿수를 가진 값을 나타내는 단순 형식입니다.A simple type representing values ranging from 1.0 x 10 -28 to approximately 7.9 x 10 28 with 28-29 significant digits. |
Double | 14 | 약 5.0 x 10 -324부터 1.7 x 10 308까지 15~16자리의 정밀도를 가진 값을 나타내는 부동 소수점 형식입니다.A floating point type representing values ranging from approximately 5.0 x 10 -324 to 1.7 x 10 308 with a precision of 15-16 digits. |
Empty | 0 | null 참조입니다.A null reference. |
Int16 | 7 | -32768과 32767 사이의 값을 가진 부호 있는 16비트 정수를 나타내는 정수 계열 형식입니다.An integral type representing signed 16-bit integers with values between -32768 and 32767. |
Int32 | 9 | -2147483648과 2147483647 사이의 값을 가진 부호 있는 32비트 정수를 나타내는 정수 계열 형식입니다.An integral type representing signed 32-bit integers with values between -2147483648 and 2147483647. |
Int64 | 11 | -9223372036854775808과 9223372036854775807 사이의 값을 가진 부호 있는 64비트 정수를 나타내는 정수 계열 형식입니다.An integral type representing signed 64-bit integers with values between -9223372036854775808 and 9223372036854775807. |
Object | 1 | 참조 또는 값 형식을 나타내는 일반 형식은 다른 |
SByte | 5 | -128과 127 사이의 값을 가진 부호 있는 8비트 정수를 나타내는 정수 계열 형식입니다.An integral type representing signed 8-bit integers with values between -128 and 127. |
Single | 13 | 대략 1.5 x 10 -45부터 3.4 x 10 38까지 7자리의 정밀도를 가진 값을 나타내는 부동 소수점 형식입니다.A floating point type representing values ranging from approximately 1.5 x 10 -45 to 3.4 x 10 38 with a precision of 7 digits. |
String | 18 | 유니코드 문자열을 나타내는 봉인된 클래스 형식입니다.A sealed class type representing Unicode character strings. |
UInt16 | 8 | 0과 65535 사이의 값을 가진 부호 없는 16비트 정수를 나타내는 정수 계열 형식입니다.An integral type representing unsigned 16-bit integers with values between 0 and 65535. |
UInt32 | 10 | 0과 4294967295 사이의 값을 가진 부호 없는 32비트 정수를 나타내는 정수 계열 형식입니다.An integral type representing unsigned 32-bit integers with values between 0 and 4294967295. |
UInt64 | 12 | 0과 18446744073709551615 사이의 값을 가진 부호 없는 64비트 정수를 나타내는 정수 계열 형식입니다.An integral type representing unsigned 64-bit integers with values between 0 and 18446744073709551615. |
예제
다음 코드 예제에서는 열거형을 사용할 수 있는 방법을 보여 줍니다 TypeCode .The following code example demonstrates how the TypeCode enumeration can be used. WriteObjectInfo 메서드 내의 의사 결정 블록에서 TypeCode Object 매개 변수의를 검사 하 고 적절 한 메시지를 콘솔에 기록 합니다.In a decision block inside the WriteObjectInfo method, the TypeCode of an Object parameter is examined, and an appropriate message is written to the console.
void WriteObjectInfo( Object^ testObject )
{
TypeCode typeCode = Type::GetTypeCode( testObject->GetType() );
switch ( typeCode )
{
case TypeCode::Boolean:
Console::WriteLine( "Boolean: {0}", testObject );
break;
case TypeCode::Double:
Console::WriteLine( "Double: {0}", testObject );
break;
default:
Console::WriteLine( "{0}: {1}", typeCode, testObject );
break;
}
}
static void WriteObjectInfo(object testObject)
{
TypeCode typeCode = Type.GetTypeCode( testObject.GetType() );
switch( typeCode )
{
case TypeCode.Boolean:
Console.WriteLine("Boolean: {0}", testObject);
break;
case TypeCode.Double:
Console.WriteLine("Double: {0}", testObject);
break;
default:
Console.WriteLine("{0}: {1}", typeCode.ToString(), testObject);
break;
}
}
Sub WriteObjectInfo(ByVal testObject As Object)
Dim typeCode As TypeCode = Type.GetTypeCode(testObject.GetType())
Select Case typeCode
Case typeCode.Boolean
Console.WriteLine("Boolean: {0}", testObject)
Case typeCode.Double
Console.WriteLine("Double: {0}", testObject)
Case Else
Console.WriteLine("{0}: {1}", typeCode.ToString(), testObject)
End Select
End Sub
설명
GetTypeCode인터페이스를 구현 하는 클래스에서 메서드를 호출 하 여 IConvertible 해당 클래스의 인스턴스에 대 한 형식 코드를 가져옵니다.Call the GetTypeCode method on classes that implement the IConvertible interface to obtain the type code for an instance of that class.
그렇지 않으면 개체의 메서드를 호출 GetType 하 여 개체 Type 를 가져온 다음 개체의 메서드를 호출 하 여 Type
GetTypeCode 개체의 형식 코드를 가져옵니다.Otherwise, call an object's GetType method to obtain its Type object, then call the Type
object's GetTypeCode method to obtain the object's type code.