Type.IsPrimitive Property
.NET Framework 4.5
Gets a value indicating whether the Type is one of the primitive types.
Namespace: System
Assembly: mscorlib (in mscorlib.dll)
The following example demonstrates the IsContextful, IsMarshalByRef, and IsPrimitive properties of the Type class. It checks whether the given type can be hosted in the context, whether it can be marshaled by reference, and whether the type is a primitive data type.
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
Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.