C# TypeInfo IsValueType

Description

TypeInfo IsValueType Gets a value indicating whether the Type is a value type.

Syntax

TypeInfo.IsValueType has the following syntax.


public bool IsValueType { get; }

Example

The following example creates a variable of type MyEnum, checks for the IsValueType property, and displays the result.


//w w  w.j  av a2  s  .  com
using System;
namespace SystemType
{
    public class MyClass
    {
        enum MyEnum
        {
            One,
            Two
        }
        public static void Main(string []args)
        {
            bool myBool = false;
            MyEnum myTestEnum = MyEnum.One;
            Type myType = myTestEnum.GetType();
            myBool = myType.IsValueType;
            Console.WriteLine("\nIs {0} a value type? {1}.", myType.FullName, myBool.ToString());
        }
    }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    System.Reflection »




EventInfo
FieldInfo
MemberInfo
MethodInfo
ParameterInfo
TypeInfo