C# TypeInfo IsPointer
Description
TypeInfo IsPointer
Gets a value indicating whether the
Type is a pointer.
Syntax
TypeInfo.IsPointer
has the following syntax.
public bool IsPointer { get; }
Example
The following example shows a use of the IsPointer property.
// w w w. j av a 2 s .c o m
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;
}
protected override bool HasElementTypeImpl()
{
if(myType.IsPointer)
{
myElementType = "pointer";
return true;
}
return false;
}
}
public class Type_HasElementTypeImpl
{
public static void Main()
{
int myInt = 0 ;
int[] myArray = new int[5];
MyTypeDelegator myType = new MyTypeDelegator(myArray.GetType());
if( myType.HasElementType)
Console.WriteLine("The type of myArray is {0}.", myType.myElementType);
else
Console.WriteLine("myArray is not an array, pointer, or reference type.");
}
}
The code above generates the following result.