Type.IsValueType Özellik

Tanım

değerinin bir değer türü olup olmadığını Type belirten bir değer alır.

public:
 property bool IsValueType { bool get(); };
public bool IsValueType { get; }
member this.IsValueType : bool
Public ReadOnly Property IsValueType As Boolean

Özellik Değeri

trueType bir değer türüyse; değilse, false.

Uygulamalar

Örnekler

Aşağıdaki örnek türünde MyEnumbir değişken oluşturur, özelliğini denetler IsValueType ve sonucu görüntüler.

using namespace System;

// Declare an enum type.
public enum class NumEnum
{
   One, Two
};

int main()
{
    bool flag = false;
    NumEnum testEnum = NumEnum::One;
      
    // Get the type of testEnum.
    Type^ t = testEnum.GetType();
      
    // Get the IsValueType property of the testEnum
    // variable.
    flag = t->IsValueType;
    Console::WriteLine("{0} is a value type: {1}", t->FullName, flag);
}
using System;

// Declare an enum type.
enum NumEnum { One, Two }

public class Example
{

    public static void Main(string []args)
    {
        bool flag = false;
        NumEnum testEnum = NumEnum.One;
        // Get the type of testEnum.
        Type t = testEnum.GetType();
        // Get the IsValueType property of the testEnum variable.
        flag = t.IsValueType;
        Console.WriteLine("{0} is a value type: {1}", t.FullName, flag);
    }
}
// The example displays the following output:
//        NumEnum is a value type: True
// Declare an enum type.
type NumEnum = One = 1 | Two = 2

let testEnum = NumEnum.One
// Get the type of testEnum.
let t = testEnum.GetType()
// Get the IsValueType property of the testEnum variable.
let flag = t.IsValueType
printfn $"{t.FullName} is a value type: {flag}"
// The example displays the following output:
//        NumEnum is a value type: True
' Declare an enum type.
Enum NumEnum
    One
    Two
End Enum
    
Public Class Example

    Public Shared Sub Main()
        Dim flag As Boolean = False
        Dim testEnum As NumEnum = NumEnum.One
        ' Get the type of myTestEnum.
        Dim t As Type = testEnum.GetType()
        ' Get the IsValueType property of the myTestEnum variable.
         flag = t.IsValueType()
         Console.WriteLine("{0} is a value type: {1}", t.FullName, flag)
     End Sub 
 End Class  
' The example displays the following output:
'       NumEnum is a value type: True

Açıklamalar

Değer türleri, bit dizileri olarak temsil edilen türlerdir; değer türleri sınıflar veya arabirimler değildir. Değer türleri bazı programlama dillerinde "yapılar" olarak adlandırılır. Sabit listeleri, değer türlerinin özel bir örneğidir.

Bu özellik, ValueType bir değer türünün kendisi olmadığından sınıfı için ValueType döndürürfalse. tüm değer türleri için temel sınıftır ve bu nedenle herhangi bir değer türü buna atanabilir. Kendisi bir değer türü olsaydı ValueType bu mümkün olmazdı. Değer türleri, türünde ValueTypebir alana atandığında kutulanır.

Bu özellik numaralandırmalar için döndürür true , ancak türün Enum kendisi için döndürmez. Bu davranışı gösteren bir örnek için bkz IsEnum. .

Bu özellik salt okunur durumdadır.

Şunlara uygulanır

Ayrıca bkz.