本文整理匯總了VB.NET中System.Type.StructLayoutAttribute屬性的典型用法代碼示例。如果您正苦於以下問題:VB.NET Type.StructLayoutAttribute屬性的具體用法?VB.NET Type.StructLayoutAttribute怎麽用?VB.NET Type.StructLayoutAttribute使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類System.Type
的用法示例。
在下文中一共展示了Type.StructLayoutAttribute屬性的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的VB.NET代碼示例。
示例1: Example
' 導入命名空間
Imports System.Runtime.InteropServices
Public Class Example
Public Shared Sub Main()
DisplayLayoutAttribute(GetType(Example).StructLayoutAttribute)
DisplayLayoutAttribute(GetType(Test1).StructLayoutAttribute)
DisplayLayoutAttribute(GetType(Test2).StructLayoutAttribute)
End Sub
Private Shared Sub DisplayLayoutAttribute( _
ByVal sla As StructLayoutAttribute)
Console.WriteLine(vbCrLf & "CharSet: " & sla.CharSet.ToString() _
& vbCrLf & " Pack: " & sla.Pack.ToString() _
& vbCrLf & " Size: " & sla.Size.ToString() _
& vbCrLf & " Value: " & sla.Value.ToString())
End Sub
Public Structure Test1
Public B1 As Byte
Public S As Short
Public B2 As Byte
End Structure
<StructLayout(LayoutKind.Explicit, Pack:=1)> _
Public Structure Test2
<FieldOffset(0)> Public B1 As Byte
<FieldOffset(1)> Public S As Short
<FieldOffset(3)> Public B2 As Byte
End Structure
End Class