Di seguito elenchiamo le varie funzioni value type e reference type.
Value Type
- Tutti i tipi di dati numerici
- Le variabili Boolean, Char e Date
- Tutte le strutture, anche se i relativi membri sono reference types
- Le enumerazioni
È possibile dichiarare un Value type tramite la parola chiave riservata, ad esempio Decimal. È inoltre possibile utilizzare la parola chiave New per inizializzare un Value type. Questo risulta particolarmente utile se il tipo presenta un costruttore che richiede parametri.
Reference Type
- String
- Tutte le matrici, anche se i relativi elementi sono tipi valore
- I tipi di classe, ad esempio Form
- Delegati
Una classe è un Reference Type. Per questo motivo, i Reference Types come Object e String sono supportati dalle classi .NET Framework. Si noti che ogni matrice è un Reference Type, anche se i suoi membri sono Value Types.
Poiché ogni Reference Type rappresenta una classe .NET Framework sottostante, è necessario utilizzare New Operator come parola chiave quando vengono inizializzate.
Nessun commento:
Posta un commento