다음을 통해 공유


Type.IsValueType 속성

Type이 값 형식인지 여부를 나타내는 값을 가져옵니다.

네임스페이스: System
어셈블리: mscorlib(mscorlib.dll)

구문

‘선언
Public ReadOnly Property IsValueType As Boolean
‘사용 방법
Dim instance As Type
Dim value As Boolean

value = instance.IsValueType
public bool IsValueType { get; }
public:
virtual property bool IsValueType {
    bool get () sealed;
}
/** @property */
public final boolean get_IsValueType ()
public final function get IsValueType () : boolean

속성 값

Type이 값 형식이면 true이고, 그렇지 않으면 false입니다.

설명

값 형식은 비트 시퀀스로 표현되는 형식이며 클래스나 인터페이스가 아닙니다. 일부 프로그래밍 언어에서는 값 형식을 "구조체"라고 합니다. 열거형은 값 형식의 특별한 경우입니다.

이 속성은 ValueType 클래스에 대해 false를 반환합니다.

이 속성은 Enum 형식 자체에 대해서가 아니라 열거형에 대해 true를 반환합니다. 이 동작을 나타내는 예를 보려면 IsEnum을 참조하십시오.

이 속성은 읽기 전용입니다.

예제

다음 예제에서는 MyEnum 형식의 변수를 만들고 IsValueType 속성을 확인하여 결과를 표시합니다.

Imports System
Imports Microsoft.VisualBasic
Namespace SystemType
    Public Class [MyClass]

        ' Declare an enum type.
        Enum MyEnum
            One
            Two
        End Enum 'MyEnum

        Public Overloads Shared Sub Main()
            Try
                Dim myBool As Boolean = False
                Dim myTestEnum As MyEnum = MyEnum.One
                ' Get the type of myTestEnum.
                Dim myType As Type = myTestEnum.GetType()
                ' Get the IsValueType property of the myTestEnum variable.
                myBool = myType.IsValueType
                Console.WriteLine(ControlChars.Cr + "Is {0} a value type? {1}.", myType.FullName, myBool.ToString())
            Catch e As Exception
                Console.WriteLine(ControlChars.Cr + "An exception occurred: {0}", e.Message.ToString())
            End Try
        End Sub 'Main
    End Class '[MyClass] 
End Namespace 'SystemType
using System;
namespace SystemType
{
    public class MyClass
    {
        // Declare an enum type.
        enum MyEnum
        {
            One,
            Two
        }
        public static void Main(string []args)
        {
            try
            {
                bool myBool = false;
                MyEnum myTestEnum = MyEnum.One;
                // Get the type of myTestEnum.
                Type myType = myTestEnum.GetType();
                // Get the IsValueType property of the myTestEnum 
                // variable.
                myBool = myType.IsValueType;
                Console.WriteLine("\nIs {0} a value type? {1}.", myType.FullName, myBool.ToString());
            }
            catch (Exception e)
            {
                Console.WriteLine("\nAn exception occurred: {0}", e.Message);
            }
        }
    }
}
using namespace System;

// Declare an enum type.
enum class MyEnum
{
   One, Two
};

int main()
{
   try
   {
      bool myBool = false;
      MyEnum myTestEnum = MyEnum::One;
      
      // Get the type of myTestEnum.
      Type^ myType = myTestEnum.GetType();
      
      // Get the IsValueType property of the myTestEnum
      // variable.
      myBool = myType->IsValueType;
      Console::WriteLine( "\nIs {0} a value type? {1}.", myType->FullName, myBool );
   }
   catch ( Exception^ e ) 
   {
      Console::WriteLine( "\nAn exception occurred: {0}", e->Message );
   }

}
package SystemType;
   
import System.*;

public class MyClass
{
    // Declare an enum type.
    static class MyEnum
    {
        private int member;

        MyEnum()
        {
            member = 0;
        } //MyEnum

        MyEnum(int n)
        {
            member = n;
        } //MyEnum

        public static final int one = 0;
        public static final int two = 1;
    } //MyEnum

    public static void main(String[] args)
    {
        try {
            boolean myBool = false;
            MyEnum myTestEnum = new MyEnum(MyEnum.one);

            // Get the type of myTestEnum.
            Type myType = myTestEnum.GetType();

            // Get the IsValueType property of the myTestEnum variable.
            myBool = myType.get_IsValueType();
            Console.WriteLine("\nIs {0} a value type? {1}.",
                myType.get_FullName(), ((System.Boolean)myBool).ToString());
        }
        catch (System.Exception e) {
            Console.WriteLine("\nAn exception occurred: {0}", e.get_Message());
        }
    } //main
} //MyClass

플랫폼

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

.NET Framework에서 모든 플래폼의 모든 버전을 지원하지는 않습니다. 지원되는 버전의 목록은 시스템 요구 사항을 참조하십시오.

버전 정보

.NET Framework

2.0, 1.1, 1.0에서 지원

.NET Compact Framework

2.0, 1.0에서 지원

참고 항목

참조

Type 클래스
Type 멤버
System 네임스페이스
TypeAttributes
Type.IsClass 속성
Type.IsInterface 속성
ValueType
IsValueTypeImpl
TypeAttributes
Type.IsClass 속성
Type.IsInterface 속성
ValueType
IsValueTypeImpl