다음을 통해 공유


Type.IsPrimitive 속성

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

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

구문

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

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

속성 값

Type이 기본 형식 중 하나이면 true이고, 그렇지 않으면 false입니다.

설명

기본 형식으로는 Boolean, Byte, SByte, Int16, UInt16, Int32, UInt32, Int64, UInt64, Char, DoubleSingle이 있습니다.

현재 Type이 제네릭 형식을 나타내거나 제네릭 형식 또는 제네릭 메서드 정의의 형식 매개 변수를 나타내는 경우 이 속성은 항상 false를 반환합니다.

예제

다음 예제에서는 Type 클래스의 IsContextful, IsMarshalByRefIsPrimitive 속성을 보여 줍니다. 이 예제에서는 지정된 형식을 컨텍스트에서 호스팅할 수 있는지 여부, 참조에 의해 마샬링할 수 있는지 여부, 형식이 기본 데이터 형식인지 여부를 확인합니다.

Imports System
Imports System.Runtime.Remoting.Contexts
Imports Microsoft.VisualBasic
Public Class MyContextBoundClass
    Inherits ContextBoundObject
    Public myString As String = "This class demonstrates the IsContextful, IsMarshalByRef, and IsPrimitive properties."
End Class 'MyContextBoundClass
Public Class MyTypeDemoClass
    Public Shared Sub Main()
        Try
            ' Determine whether the types can be hosted in a Context.
            Console.WriteLine("The Contextful property for the {0} type is {1}.", GetType(MyTypeDemoClass).Name, GetType(MyTypeDemoClass).IsContextful.ToString())
            Console.WriteLine("The Contextful property for the {0} type is {1}.", GetType(MyContextBoundClass).Name, GetType(MyContextBoundClass).IsContextful.ToString())
            ' Determine whether the types are marshalled by reference.
            Console.WriteLine("The MarshalByRef property of {0} is {1}.", GetType(MyTypeDemoClass).Name, GetType(MyTypeDemoClass).IsMarshalByRef.ToString())
            Console.WriteLine("The MarshalByRef property of {0} is {1}.", GetType(MyContextBoundClass).Name, GetType(MyContextBoundClass).IsMarshalByRef.ToString())
            ' Determine whether the types are primitive datatypes.
            Console.WriteLine("Is {0} a primitive data type? {1}.", GetType(Integer).Name, GetType(Integer).IsPrimitive.ToString())
            Console.WriteLine("Is {0} a primitive data type? {1}.", GetType(String).Name, GetType(String).IsPrimitive.ToString())
        Catch e As Exception
            Console.WriteLine("An exception occurred: " + e.Message.ToString())
        End Try
    End Sub 'Main
End Class 'MyTypeDemoClass
using System;
using System.Runtime.Remoting.Contexts;
public class MyContextBoundClass: ContextBoundObject
{
    public string myString = "This class demonstrates the IsContextful, IsMarshalByRef, and IsPrimitive properties.";
}
public class MyTypeDemoClass
{
    public static void Main()
    {
        try
        {
            // Determine whether the types can be hosted in a Context.
            Console.WriteLine ("The IsContextful property for the {0} type is {1}.", typeof(MyTypeDemoClass).Name, typeof(MyTypeDemoClass).IsContextful);
            Console.WriteLine ("The IsContextful property for the {0} type is {1}.", typeof(MyContextBoundClass).Name, typeof(MyContextBoundClass).IsContextful);

            // Determine whether the types are marshalled by reference.
            Console.WriteLine ("The MarshalByRef property of {0} is {1}.", typeof(MyTypeDemoClass).Name, typeof(MyTypeDemoClass).IsMarshalByRef);
            Console.WriteLine ("The MarshalByRef property of {0} is {1}.", typeof(MyContextBoundClass).Name, typeof(MyContextBoundClass).IsMarshalByRef);
            
            // Determine whether the types are primitive datatypes.
            Console.WriteLine ("Is {0} is a primitive data type? {1}.", typeof(int).Name, typeof(int).IsPrimitive);
            Console.WriteLine ("Is {0} a primitive data type? {1}.", typeof(string).Name, typeof(string).IsPrimitive);
        } 
        catch (Exception e)
        {
            Console.WriteLine("An exception occurred: " + e.Message);
        }
    }
}
using namespace System;
using namespace System::Runtime::Remoting::Contexts;
public ref class MyContextBoundClass: public ContextBoundObject
{
public:
   String^ myString;
};

public ref class MyTypeDemoClass
{
public:
   void Demo()
   {
      try
      {
         // Determine whether the types can be hosted in a Context.
         Console::WriteLine( "The IsContextful property for the {0} type is {1}.", MyTypeDemoClass::typeid->Name, MyTypeDemoClass::typeid->IsContextful );
         Console::WriteLine( "The IsContextful property for the {0} type is {1}.", MyContextBoundClass::typeid->Name, MyContextBoundClass::typeid->IsContextful );
         
         // Determine whether the types are marshalled by reference.
         Console::WriteLine( "The MarshalByRef property of {0} is {1}.", MyTypeDemoClass::typeid->Name, MyTypeDemoClass::typeid->IsMarshalByRef );
         Console::WriteLine( "The MarshalByRef property of {0} is {1}.", MyContextBoundClass::typeid->Name, MyContextBoundClass::typeid->IsMarshalByRef );
         
         // Determine whether the types are primitive datatypes.
         Console::WriteLine( "Is {0} is a primitive data type? {1}.", int::typeid->Name, int::typeid->IsPrimitive );
         Console::WriteLine( "Is {0} a primitive data type? {1}.", String::typeid->Name, String::typeid->IsPrimitive );
      }
      catch ( Exception^ e ) 
      {
         Console::WriteLine( "An exception occurred: {0}", e->Message );
      }
   }
};

int main()
{
   MyTypeDemoClass^ mtdc = gcnew MyTypeDemoClass;
   mtdc->Demo();
}
import System.*;
import System.Runtime.Remoting.Contexts.*;

public class MyContextBoundClass extends ContextBoundObject
{
    public String myString = "This class demonstrates the IsContextful, "
        +"IsMarshalByRef, and IsPrimitive properties.";
} //MyContextBoundClass

public class MyTypeDemoClass
{
    public static void main(String[] args)
    {
        try {
            // Determine whether the types can be hosted in a Context.
            Console.WriteLine("The IsContextful property for the"
                +" {0} type is {1}.", MyTypeDemoClass.class.ToType().get_Name(),
                System.Convert.ToString(MyTypeDemoClass.class.ToType().
                get_IsContextful()));
            Console.WriteLine("The IsContextful property for the"
                +" {0} type is {1}.", MyContextBoundClass.class.ToType().
                get_Name(), System.Convert.ToString(MyContextBoundClass.class.
                ToType().get_IsContextful()));

            // Determine whether the types are marshalled by reference.
            Console.WriteLine("The MarshalByRef property of {0} is {1}.",
                MyTypeDemoClass.class.ToType().get_Name(),
                System.Convert.ToString(MyTypeDemoClass.class.ToType().
                get_IsMarshalByRef()));
            Console.WriteLine("The MarshalByRef property of {0} is {1}.",
                MyContextBoundClass.class.ToType().get_Name(),
                System.Convert.ToString(MyContextBoundClass.class.ToType().
                get_IsMarshalByRef()));

            // Determine whether the types are primitive datatypes.
            Console.WriteLine("Is {0} is a primitive data type? {1}.",
                int.class.ToType().get_Name(),
                System.Convert.ToString(int.class.ToType().get_IsPrimitive()));
            Console.WriteLine("Is {0} a primitive data type? {1}.",
                String.class.ToType().get_Name(),System.Convert.ToString(
                String.class.ToType().get_IsPrimitive()));
        }
        catch (System.Exception e) {
            Console.WriteLine("An exception occurred: " + e.get_Message());
        }
    } //main
} //MyTypeDemoClass

플랫폼

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 네임스페이스
Boolean 구조체
Byte 구조체
SByte 구조체
Int16 구조체
UInt16
Int32 구조체
UInt32
Int64 구조체
UInt64
Char 구조체
Double 구조체
Single 구조체
IsPrimitiveImpl