|
Il presente articolo è stato tradotto automaticamente. Passare il puntatore sulle frasi nell'articolo per visualizzare il testo originale. Ulteriori informazioni.
|
Traduzione
Originale
|
Classe Hashtable
Spazio dei nomi: System.Collections
Assembly: mscorlib (in mscorlib.dll)
Il tipo Hashtable espone i seguenti membri.
| Nome | Descrizione | |
|---|---|---|
![]() ![]() | Hashtable() | |
![]() ![]() | Hashtable(IDictionary) | |
![]() ![]() | Hashtable(IEqualityComparer) | |
![]() ![]() | Hashtable(Int32) | |
![]() ![]() | Hashtable(IDictionary, IEqualityComparer) | |
![]() ![]() | Hashtable(IDictionary, Single) | |
![]() ![]() | Hashtable(IHashCodeProvider, IComparer) | Obsoleta. |
![]() ![]() | Hashtable(Int32, IEqualityComparer) | |
![]() ![]() | Hashtable(Int32, Single) | |
![]() | Hashtable(SerializationInfo, StreamingContext) | |
![]() ![]() | Hashtable(IDictionary, IHashCodeProvider, IComparer) | Obsoleta. |
![]() ![]() | Hashtable(IDictionary, Single, IEqualityComparer) | |
![]() ![]() | Hashtable(Int32, IHashCodeProvider, IComparer) | Obsoleta. |
![]() ![]() | Hashtable(Int32, Single, IEqualityComparer) | |
![]() | Hashtable(IDictionary, Single, IHashCodeProvider, IComparer) | Obsoleta. |
![]() | Hashtable(Int32, Single, IHashCodeProvider, IComparer) | Obsoleta. |
| Nome | Descrizione | |
|---|---|---|
![]() ![]() | comparer | Obsoleta. |
![]() ![]() | Count | |
![]() ![]() | EqualityComparer | |
![]() ![]() | hcp | Obsoleta. |
![]() ![]() | IsFixedSize | |
![]() ![]() | IsReadOnly | |
![]() ![]() | IsSynchronized | |
![]() ![]() | Item | |
![]() ![]() | Keys | |
![]() ![]() | SyncRoot | |
![]() ![]() | Values |
| Nome | Descrizione | |
|---|---|---|
![]() ![]() | Add | |
![]() ![]() | Clear | |
![]() ![]() | Clone | |
![]() ![]() | Contains | |
![]() ![]() | ContainsKey | |
![]() ![]() | ContainsValue | |
![]() ![]() | CopyTo | |
![]() ![]() | Equals(Object) | |
![]() ![]() | Finalize | |
![]() ![]() | GetEnumerator | |
![]() ![]() | GetHash | |
![]() ![]() | GetHashCode | |
![]() | GetObjectData | |
![]() ![]() | GetType | |
![]() ![]() | KeyEquals | |
![]() ![]() | MemberwiseClone | |
![]() | OnDeserialization | |
![]() ![]() | Remove | |
![]() ![]() ![]() | Synchronized | |
![]() ![]() | ToString |
| Nome | Descrizione | |
|---|---|---|
![]() | AsParallel | |
![]() | AsQueryable | |
![]() ![]() | Cast<TResult> | |
![]() ![]() | OfType<TResult> |
Nota |
|---|
using System; using System.Collections; class Example { public static void Main() { // Create a new hash table. // Hashtable openWith = new Hashtable(); // Add some elements to the hash table. There are no // duplicate keys, but some of the values are duplicates. openWith.Add("txt", "notepad.exe"); openWith.Add("bmp", "paint.exe"); openWith.Add("dib", "paint.exe"); openWith.Add("rtf", "wordpad.exe"); // The Add method throws an exception if the new key is // already in the hash table. try { openWith.Add("txt", "winword.exe"); } catch { Console.WriteLine("An element with Key = \"txt\" already exists."); } // The Item property is the default property, so you // can omit its name when accessing elements. Console.WriteLine("For key = \"rtf\", value = {0}.", openWith["rtf"]); // The default Item property can be used to change the value // associated with a key. openWith["rtf"] = "winword.exe"; Console.WriteLine("For key = \"rtf\", value = {0}.", openWith["rtf"]); // If a key does not exist, setting the default Item property // for that key adds a new key/value pair. openWith["doc"] = "winword.exe"; // ContainsKey can be used to test keys before inserting // them. if (!openWith.ContainsKey("ht")) { openWith.Add("ht", "hypertrm.exe"); Console.WriteLine("Value added for key = \"ht\": {0}", openWith["ht"]); } // When you use foreach to enumerate hash table elements, // the elements are retrieved as KeyValuePair objects. Console.WriteLine(); foreach( DictionaryEntry de in openWith ) { Console.WriteLine("Key = {0}, Value = {1}", de.Key, de.Value); } // To get the values alone, use the Values property. ICollection valueColl = openWith.Values; // The elements of the ValueCollection are strongly typed // with the type that was specified for hash table values. Console.WriteLine(); foreach( string s in valueColl ) { Console.WriteLine("Value = {0}", s); } // To get the keys alone, use the Keys property. ICollection keyColl = openWith.Keys; // The elements of the KeyCollection are strongly typed // with the type that was specified for hash table keys. Console.WriteLine(); foreach( string s in keyColl ) { Console.WriteLine("Key = {0}", s); } // Use the Remove method to remove a key/value pair. Console.WriteLine("\nRemove(\"doc\")"); openWith.Remove("doc"); if (!openWith.ContainsKey("doc")) { Console.WriteLine("Key \"doc\" is not found."); } } } /* This code example produces the following output: An element with Key = "txt" already exists. For key = "rtf", value = wordpad.exe. For key = "rtf", value = winword.exe. Value added for key = "ht": hypertrm.exe Key = dib, Value = paint.exe Key = txt, Value = notepad.exe Key = ht, Value = hypertrm.exe Key = bmp, Value = paint.exe Key = rtf, Value = winword.exe Key = doc, Value = winword.exe Value = paint.exe Value = notepad.exe Value = hypertrm.exe Value = paint.exe Value = winword.exe Value = winword.exe Key = dib Key = txt Key = ht Key = bmp Key = rtf Key = doc Remove("doc") Key "doc" is not found. */
Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (ruoli di base del server non supportati), Windows Server 2008 R2 (ruoli di base del server supportati con SP1 o versione successiva, Itanium non supportato)
.NET Framework non supporta tutte le versioni di ciascuna piattaforma. Per un elenco delle versioni supportate, vedere Requisiti di sistema di .NET Framework.
