C# Type IsPrimitive
Description
Type IsPrimitive
gets a value indicating whether the
Type is one of the primitive types.
Syntax
Type.IsPrimitive
has the following syntax.
public bool IsPrimitive { get; }
Example
The following example demonstrates the IsContextful, IsMarshalByRef, and IsPrimitive properties of the Type class.
/* w w w .j a va 2s . co m*/
using System;
using System.Runtime.Remoting.Contexts;
public class MyContextBoundClass: ContextBoundObject
{
public string myString = "This class demonstrates the IsPrimitive property.";
}
public class MyTypeDemoClass
{
public static void Main()
{
try
{
Console.WriteLine (typeof(int).IsPrimitive);
Console.WriteLine (typeof(string).IsPrimitive);
}
catch (Exception e)
{
Console.WriteLine("An exception occurred: " + e.Message);
}
}
}
The code above generates the following result.