C# Type IsPrimitiveImpl
Description
Type IsPrimitiveImpl
when overridden in a derived class,
implements the IsPrimitive property and determines whether the Type is
one of the primitive types.
Syntax
Type.IsPrimitiveImpl
has the following syntax.
protected abstract bool IsPrimitiveImpl()
Returns
Type.IsPrimitiveImpl
method returns true if the Type is one of the primitive types; otherwise, false.
Example
The following example determines whether the given type is a primitive type and displays the result.
/*from w w w. j a v a 2s.c om*/
using System;
using System.Reflection;
public class MyTypeDelegatorClass : TypeDelegator
{
public string myElementType = null;
private Type myType = null ;
public MyTypeDelegatorClass(Type myType) : base(myType)
{
this.myType = myType;
}
protected override bool IsPrimitiveImpl()
{
if(myType.IsPrimitive)
{
myElementType = "primitive";
return true;
}
return false;
}
}
public class MyTypeDemoClass
{
public static void Main()
{
MyTypeDelegatorClass myType;
myType = new MyTypeDelegatorClass(typeof(int));
Console.WriteLine(myType.IsPrimitive);
}
}
The code above generates the following result.