Type.IsValueType Property
Assembly: mscorlib (in mscorlib.dll)
Value types are those that are represented as sequences of bits; value types are not classes or interfaces. These are referred to as "structs" in some programming languages. Enums are a special case of value types.
This property returns false for the ValueType class.
This property returns true for enumerations, but not for the Enum type itself. For an example that demonstrates this behavior, see IsEnum.
This property is read-only.
The following example creates a variable of type MyEnum, checks for the IsValueType property, and displays the result.
using namespace System; // Declare an enum type. enum class MyEnum { One, Two }; int main() { try { bool myBool = false; MyEnum myTestEnum = MyEnum::One; // Get the type of myTestEnum. Type^ myType = myTestEnum.GetType(); // Get the IsValueType property of the myTestEnum // variable. myBool = myType->IsValueType; Console::WriteLine( "\nIs {0} a value type? {1}.", myType->FullName, myBool ); } catch ( Exception^ e ) { Console::WriteLine( "\nAn exception occurred: {0}", e->Message ); } }
package SystemType;
import System.*;
public class MyClass
{
// Declare an enum type.
static class MyEnum
{
private int member;
MyEnum()
{
member = 0;
} //MyEnum
MyEnum(int n)
{
member = n;
} //MyEnum
public static final int one = 0;
public static final int two = 1;
} //MyEnum
public static void main(String[] args)
{
try {
boolean myBool = false;
MyEnum myTestEnum = new MyEnum(MyEnum.one);
// Get the type of myTestEnum.
Type myType = myTestEnum.GetType();
// Get the IsValueType property of the myTestEnum variable.
myBool = myType.get_IsValueType();
Console.WriteLine("\nIs {0} a value type? {1}.",
myType.get_FullName(), ((System.Boolean)myBool).ToString());
}
catch (System.Exception e) {
Console.WriteLine("\nAn exception occurred: {0}", e.get_Message());
}
} //main
} //MyClass
Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.