Type.IsPrimitiveImpl Method ()
.NET Framework (current version)
When overridden in a derived class, implements the IsPrimitive property and determines whether the Type is one of the primitive types.
Assembly: mscorlib (in mscorlib.dll)
The following example determines whether the given type is a primitive type and displays the result.
Imports System Imports System.Reflection Imports Microsoft.VisualBasic Public Class MyTypeDelegatorClass Inherits TypeDelegator Public myElementType As String = Nothing Private myType As Type = Nothing Public Sub New(ByVal myType As Type) MyBase.New(myType) Me.myType = myType End Sub 'NewNew ' Override the IsPrimitiveImpl method. Protected Overrides Function IsPrimitiveImpl() As Boolean ' Determine whether the type is a primitive type. If myType.IsPrimitive Then myElementType = "primitive" Return True End If Return False End Function 'IsPrimitiveImpl End Class 'MyTypeDelegatorClass Public Class MyTypeDemoClass Public Shared Sub Main() Try Console.WriteLine("Determine whether int is a primitive type.") Dim myType As MyTypeDelegatorClass myType = New MyTypeDelegatorClass(GetType(Integer)) ' Determine whether int is a primitive type. If myType.IsPrimitive Then Console.WriteLine(GetType(Integer).ToString() + " is a primitive type.") Else Console.WriteLine(GetType(Integer).ToString() + " is not a primitive type.") End If Console.WriteLine(ControlChars.NewLine + "Determine whether string is a primitive type.") myType = New MyTypeDelegatorClass(GetType(String)) ' Determine whether string is a primitive type. If myType.IsPrimitive Then Console.WriteLine(GetType(String).ToString() + " is a primitive type.") Else Console.WriteLine(GetType(String).ToString() + " is not a primitive type.") End If Catch e As Exception Console.WriteLine("Exception: {0}", e.Message.ToString()) End Try End Sub 'Main End Class 'MyTypeDemoClass
.NET Framework
Available since 1.1
Portable Class Library
Supported in: portable .NET platforms
Silverlight
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Available since 1.1
Portable Class Library
Supported in: portable .NET platforms
Silverlight
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Show: