Description
The IsValueType
property of the TypeDescription
class indicates whether the target type is a value type. A value type is a type that holds data directly, as opposed to a reference type, which holds a reference to the data. Common examples of value types include primitive types like int
, float
, and bool
, as well as structs.
Usage
To determine if a type described by a TypeDescription
instance is a value type, access the IsValueType
property. This property returns a bool
indicating whether the type is a value type.
Example
// Example of using the IsValueType property
TypeDescription typeDescription = TypeLibrary.GetTypeDescription(typeof(int));
if (typeDescription.IsValueType)
{
// This will be true for int, as it is a value type
// Perform operations specific to value types
Console.WriteLine("The type is a value type.");
}
else
{
// Handle reference types
Console.WriteLine("The type is not a value type.");
}