Type.IsAutoLayout Özellik
Tanım
Önemli
Bazı bilgiler ürünün ön sürümüyle ilgilidir ve sürüm öncesinde önemli değişiklikler yapılmış olabilir. Burada verilen bilgilerle ilgili olarak Microsoft açık veya zımni hiçbir garanti vermez.
Geçerli türdeki alanların ortak dil çalışma zamanı tarafından otomatik olarak yerleştirilip yerleştirildiğini belirten bir değer alır.
public:
property bool IsAutoLayout { bool get(); };
public bool IsAutoLayout { get; }
member this.IsAutoLayout : bool
Public ReadOnly Property IsAutoLayout As Boolean
Özellik Değeri
true
Attributes geçerli türün özelliği içeriyorsa AutoLayout; değilse, false.
Uygulamalar
Örnekler
Aşağıdaki örnek türün bir örneğini oluşturur ve özelliğini görüntüler IsAutoLayout .
using System;
using System.Runtime.InteropServices;
// The Demo class is attributed as AutoLayout.
[StructLayoutAttribute(LayoutKind.Auto)]
public class Demo
{
}
public class Example
{
public static void Main()
{
// Create an instance of the Type class using the GetType method.
Type myType=typeof(Demo);
// Get and display the IsAutoLayout property of the
// Demoinstance.
Console.WriteLine("\nThe AutoLayout property for the Demo class is {0}.",
myType.IsAutoLayout);
}
}
open System.Runtime.InteropServices
// The Demo class is attributed as AutoLayout.
[<StructLayoutAttribute(LayoutKind.Auto)>]
type Demo = class end
// Create an instance of the Type class using the GetType method.
let myType = typeof<Demo>
// Get and display the IsAutoLayout property of the
// Demoinstance.
printfn $"\nThe AutoLayout property for the Demo class is {myType.IsAutoLayout}."
Imports System.Runtime.InteropServices
' The Demo class is has the AutoLayout attribute.
<StructLayoutAttribute(LayoutKind.Auto)> _
Public Class Demo
End Class
Public Class Example
Public Shared Sub Main()
' Get the Type object for the Demo class.
Dim myType As Type = GetType(Demo)
' Get and display the IsAutoLayout property of the
' Demo class.
Console.WriteLine("The AutoLayout property for the Demo class is '{0}'.", _
myType.IsAutoLayout.ToString())
End Sub
End Class
Açıklamalar
Bu özellik kolaylık sağlamak için sağlanır. Alternatif olarak, tür düzeni özniteliklerini seçmek ve ardından ayarlanıp ayarlanmadığını TypeAttributes.AutoLayout test etmek için numaralandırma değerini kullanabilirsinizTypeAttributes.LayoutMask. TypeAttributes.AutoLayoutveTypeAttributes.ExplicitLayout numaralandırma değerleri, TypeAttributes.SequentialLayout tür alanlarının bellekte nasıl yerleştirileceğine işaret eder.
Dinamik türler için türü oluşturduğunuzda belirtebilirsiniz TypeAttributes.AutoLayout . Kodda, çalışma zamanının StructLayoutAttributeLayoutKind.Auto sınıfı düzenlemek için uygun yolu belirlemesine izin vermek için türüne numaralandırma değeriyle özniteliğini uygulayın.
Uyarı
bir türe GetCustomAttributes uygulanıp uygulanmadığını StructLayoutAttribute belirlemek için yöntemini kullanamazsınız.
Geçerli Type , bir genel tür oluşturulduysa, bu özellik türün oluşturulduğu genel tür tanımına uygulanır. Örneğin, geçerli Type değeri (MyGenericType(Of Integer) Visual Basic'te) temsil MyGenericType<int> ederse, bu özelliğin değeriMyGenericType<T>.
Geçerli Type , genel bir tür veya genel yöntemin tanımında tür parametresini temsil ederse, bu özellik her zaman döndürür false.