VBFixedArrayAttribute Classe

Definizione

Indica che una matrice in una struttura o una variabile non locale deve essere considerata come matrice a lunghezza fissa.

public ref class VBFixedArrayAttribute sealed : Attribute
[System.AttributeUsage(System.AttributeTargets.Field, AllowMultiple=false, Inherited=false)]
public sealed class VBFixedArrayAttribute : Attribute
[<System.AttributeUsage(System.AttributeTargets.Field, AllowMultiple=false, Inherited=false)>]
type VBFixedArrayAttribute = class
    inherit Attribute
Public NotInheritable Class VBFixedArrayAttribute
Inherits Attribute
Ereditarietà
VBFixedArrayAttribute
Attributi

Esempio

Structure Book
    <VBFixedArray(4)> Public Chapter() As Integer
End Structure

Sub WriteData()
    Dim FileNum As Integer = FreeFile()
    Dim MyBook As Book
    ReDim MyBook.Chapter(4)
    ' Add code to populate the array.
    MyBook.Chapter(0) = 1
    MyBook.Chapter(1) = 2
    MyBook.Chapter(2) = 3
    MyBook.Chapter(3) = 4
    MyBook.Chapter(4) = 5
    ' Write the array to a file.
    FileOpen(FileNum, "C:\testfile", OpenMode.Binary,
             OpenAccess.Write, OpenShare.Default)
    FilePut(FileNum, MyBook) ' Write data.
    FileClose(FileNum)
End Sub

Note

è VBFixedArrayAttribute informativo e non alloca alcuna risorsa di archiviazione. Lo scopo di questo attributo è modificare il modo in cui le matrici nelle strutture e le variabili non locali vengono usate da metodi o chiamate API che riconoscono .VBFixedArrayAttribute Tenere presente che questo attributo non converte una matrice di lunghezza variabile in una matrice fissa e che è comunque necessario allocare l'archiviazione di matrici usando Dim istruzioni o ReDim .

Commenti

Visual Basic matrici sono di lunghezza variabile per impostazione predefinita. Questo attributo è utile quando si usano funzioni di input e output di file Visual Basic, ad esempio FileGet e FilePut e chiamate API che richiedono matrici a lunghezza fissa.

Costruttori

Nome Descrizione
VBFixedArrayAttribute(Int32, Int32)

Inizializza il valore della Bounds proprietà .

VBFixedArrayAttribute(Int32)

Inizializza il valore della Bounds proprietà .

Proprietà

Nome Descrizione
Bounds

Restituisce i limiti della matrice.

Length

Restituisce le dimensioni della matrice.

TypeId

Se implementato in una classe derivata, ottiene un identificatore univoco per questo Attribute.

(Ereditato da Attribute)

Metodi

Nome Descrizione
Equals(Object)

Restituisce un valore che indica se questa istanza è uguale a un oggetto specificato.

(Ereditato da Attribute)
GetHashCode()

Restituisce il codice hash per questa istanza.

(Ereditato da Attribute)
GetType()

Ottiene il Type dell'istanza corrente.

(Ereditato da Object)
IsDefaultAttribute()

Quando sottoposto a override in una classe derivata, indica se il valore di questa istanza è il valore predefinito per la classe derivata.

(Ereditato da Attribute)
Match(Object)

Quando sottoposto a override in una classe derivata, restituisce un valore che indica se questa istanza è uguale a un oggetto specificato.

(Ereditato da Attribute)
MemberwiseClone()

Crea una copia superficiale del Objectcorrente.

(Ereditato da Object)
ToString()

Restituisce una stringa che rappresenta l'oggetto corrente.

(Ereditato da Object)

Implementazioni dell'interfaccia esplicita

Nome Descrizione
_Attribute.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr)

Esegue il mapping di un set di nomi a un set corrispondente di identificatori dispatch.

(Ereditato da Attribute)
_Attribute.GetTypeInfo(UInt32, UInt32, IntPtr)

Recupera le informazioni sul tipo per un oggetto, che può essere utilizzato per ottenere le informazioni sul tipo per un'interfaccia.

(Ereditato da Attribute)
_Attribute.GetTypeInfoCount(UInt32)

Recupera il numero di interfacce di informazioni sul tipo fornite da un oggetto (0 o 1).

(Ereditato da Attribute)
_Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

Fornisce l'accesso alle proprietà e ai metodi esposti da un oggetto .

(Ereditato da Attribute)

Si applica a

Vedi anche