IsPointer Property

Type.IsPointer Property

[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]

Gets a value indicating whether the Type is a pointer.

Namespace:  System
Assembly:  mscorlib (in mscorlib.dll)

'Declaration
Public ReadOnly Property IsPointer As Boolean

Property Value

Type: System.Boolean
true if the Type is a pointer; otherwise, false.

If the current Type represents a generic type, or a type parameter in the definition of a generic type or generic method, this property always returns false.

This property is read-only.

The following example shows a use of the IsPointer property.


Imports System.Reflection
Public Class MyTypeDelegator
   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 'New
   ' Override Type.HasElementTypeImpl().
   Protected Overrides Function HasElementTypeImpl() As Boolean
      ' Determine whether the type is an array.
      If myType.IsArray Then
         myElementType = "array"
         Return True
      End If
      ' Determine whether the type is a reference.
      If myType.IsByRef Then
         myElementType = "reference"
         Return True
      End If
      ' Determine whether the type is a pointer.
      If myType.IsPointer Then
         myElementType = "pointer"
         Return True
      End If
      ' The type is not a reference, array, or pointer type.
      Return False
   End Function 'HasElementTypeImpl
End Class 'MyTypeDelegator
Public Class Example
   Public Shared Sub Demo(ByVal outputBlock As System.Windows.Controls.TextBlock)
      Try
         Dim myInt As Integer = 0
         Dim myArray(4) As Integer
         Dim myType As New MyTypeDelegator(myArray.GetType())
         outputBlock.Text &= ControlChars.NewLine + "Determine whether a variable refers to an array or pointer or reference type." + ControlChars.NewLine & vbCrLf
         ' Determine whether myType is an array, pointer, reference type.  
         If myType.HasElementType Then
            outputBlock.Text += String.Format("The type of myArray is {0}.", myType.myElementType.ToString()) & vbCrLf
         Else
            outputBlock.Text += String.Format("myArray is not an array, pointer, or reference type.") & vbCrLf
         End If
         myType = New MyTypeDelegator(myInt.GetType())
         ' Determine whether myType is an array, pointer, reference type. 
         If myType.HasElementType Then
            outputBlock.Text += String.Format("The type of myInt is {0}.", myType.myElementType.ToString()) & vbCrLf
         Else
            outputBlock.Text += String.Format("myInt is not an array, pointer, or reference type.") & vbCrLf
         End If
      Catch e As Exception
         outputBlock.Text += String.Format("Exception: {0}", e.Message.ToString()) & vbCrLf
      End Try
   End Sub 'Main
End Class 'Type_HasElementTypeImpl


Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Windows Phone

Show:
© 2017 Microsoft