Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Type.IsPointer Property
Microsoft Silverlight will reach end of support after October 2021. Learn more.
Gets a value indicating whether the Type is a pointer.
Namespace: System
Assembly: mscorlib (in mscorlib.dll)
Syntax
'Declaration
Public ReadOnly Property IsPointer As Boolean
public bool IsPointer { get; }
Property Value
Type: System.Boolean
true if the Type is a pointer; otherwise, false.
Remarks
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.
Examples
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
using System;
using System.Reflection;
public class MyTypeDelegator : TypeDelegator
{
public string myElementType = null;
private Type myType = null;
public MyTypeDelegator(Type myType)
: base(myType)
{
this.myType = myType;
}
// Override Type.HasElementTypeImpl().
protected override bool HasElementTypeImpl()
{
// Determine whether the type is an array.
if (myType.IsArray)
{
myElementType = "array";
return true;
}
// Determine whether the type is a reference.
if (myType.IsByRef)
{
myElementType = "reference";
return true;
}
// Determine whether the type is a pointer.
if (myType.IsPointer)
{
myElementType = "pointer";
return true;
}
// Return false if the type is not a reference, array, or pointer type.
return false;
}
}
public class Example
{
public static void Demo(System.Windows.Controls.TextBlock outputBlock)
{
try
{
int myInt = 0;
int[] myArray = new int[5];
MyTypeDelegator myType = new MyTypeDelegator(myArray.GetType());
// Determine whether myType is an array, pointer, reference type.
outputBlock.Text += String.Format("\nDetermine whether a variable is an array, pointer, or reference type.\n") + "\n";
if (myType.HasElementType)
outputBlock.Text += String.Format("The type of myArray is {0}.", myType.myElementType) + "\n";
else
outputBlock.Text += String.Format("myArray is not an array, pointer, or reference type.") + "\n";
myType = new MyTypeDelegator(myInt.GetType());
// Determine whether myType is an array, pointer, reference type.
if (myType.HasElementType)
outputBlock.Text += String.Format("The type of myInt is {0}.", myType.myElementType) + "\n";
else
outputBlock.Text += String.Format("myInt is not an array, pointer, or reference type.") + "\n";
}
catch (Exception e)
{
outputBlock.Text += String.Format("Exception: {0}", e.Message) + "\n";
}
}
}
Version Information
Silverlight
Supported in: 5, 4, 3
Silverlight for Windows Phone
Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0
XNA Framework
Supported in: Xbox 360, Windows Phone OS 7.0
Platforms
For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.