dotnet / dotnet/dotnet-api-docs
Documentation Issue: ConditionalWeakTable<TKey,TValue> Class
- Dominant language
- C#
- Stars
- 949
- Forks
- 1.7k
- Avg merge
- 3d 27m
- Merged PRs (30d)
- 49
Description
### Type of issue
Code doesn't work
### Description
1) The provided C# example fails to compile due to a conversion error. Example fixes:
A) Replace `cwt.TryGetValue(wr2.Target, out data)` with `cwt.TryGetValue((ManagedClass)wr2.Target, out data)`
B) Replace `var cwt = new ConditionalWeakTable();` with `var cwt = new ConditionalWeakTable();`
2) Possibly it's worth adding a note that the example may fail to function in debug mode, since in-scope variables are ineligible for collection during debug.
### Page URL
https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.conditionalweaktable-2?view=net-8.0&redirectedfrom=MSDN
### Content source URL
https://github.com/dotnet/dotnet-api-docs/blob/main/xml/System.Runtime.CompilerServices/ConditionalWeakTable`2.xml
### Document Version Independent Id
6a9b0e31-d0a6-c930-7959-20ac6f03ec4a
### Article author
@dotnet-bot
Contributor guide
Assessment
This issue has not been assessed yet.