< Day Day Up > |
The VBFixedArrayAttribute attribute is used to ensure that files written using the FileSystem methods are compatible with previous versions of Visual Basic. A fixed- size array in previous versions of Visual Basic was an array declared with a size in a user -defined type. Type Team Members(10) As String End Type This example shows a user-defined type with a fixed-size array of strings in it. When a user-defined type with a fixed-size array was written to disk, it included a special header containing the size of the array. For the array to be read properly in Visual Basic .NET, the corresponding class or structure has to specify the VBFixedArrayAttribute . Class Team <VBFixedArrayAttribute(10)> Public Members() As String End Class Module Test Sub Main() Dim x As Team FileOpen(FileNum, "team.txt", OpenMode.Binary, _ OpenAccess.Write, OpenShare.Default) FileGet(1, x) FileClose(1) End Sub End Module Public ReadOnly Property Bounds() As Integer() The Bounds property returns a one-dimensional array of the upper bounds of each dimension. Public ReadOnly Property Length() As Integer The Length property returns the number of dimensions of the fixed-size array. Public Sub New(ByVal UpperBound1 As Integer) Public Sub New(ByVal UpperBound1 As Integer, _ ByVal UpperBound2 As Integer) The VBFixedArrayAttribute constructor specifies the upper bound or upper bounds of the array. |
< Day Day Up > |