ConditionalWeakTable<TKey, TValue>::TryGetValue Method (TKey, TValue%)
Gets the value of the specified key.
Assembly: mscorlib (in mscorlib.dll)
| Exception | Condition |
|---|---|
| ArgumentNullException | key is null. |
If the key is garbage-collected during this operation, the method may return false and set value to the default value (as if the key were not present).
The following example defines a MainClass class and a MainInfo class, which provides information about the MainClass instance. The example calls the Add, GetOrCreateValue, and GetValue methods to add key/value pairs to a ConditionalWeakTable<TKey, TValue> table. In each case, the example calls the TryGetValue method to confirm that the key/value pair has been added to the table.
requires full trust for the immediate caller. This member cannot be used by partially trusted or transparent code.
Available since 8
.NET Framework
Available since 4.0
Portable Class Library
Supported in: portable .NET platforms
Silverlight
Available since 4.0
Windows Phone Silverlight
Available since 8.0
Windows Phone
Available since 8.1