question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Convert `Hashtable` usage to `Dictionary<TKey, TValue`

See original GitHub issue

Is your feature request related to a problem? Please describe

Hashtable has been used all over the winforms code base.

Describe the solution you’d like and alternatives you’ve considered

Refactoring to Dictionary<TKey, TValue is explicit in its typing and avoids boxing.

The changes should not affect Public APIs.

System.Windows.Forms: 31 references System.Windows.Forms.Design: 126 references

Related: #8140, #2644

Issue Analytics

  • State:open
  • Created 10 months ago
  • Comments:8 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
halgabcommented, Mar 12, 2023

I see that ContextMenuStripGroupCollection, which is internal, overrides DictionaryBase, which is basically just a wrapper around a HashTable with extra events we’re not using. As part of this issue, do you agree it would be a good idea for this class to use a Dictionary<string, ContextMenuStripGroup> directly instead?

0reactions
elachlancommented, Dec 3, 2022

ImmutablePropertyDescriptorGridEntry.PropertyValue is something I am not 100% sure on. It creates an HashTable into an IDictionary variable, then passes that to TypeConverter.CreateInstance. I imagine the underlying converter probably relies on it being a hashtable? Anyone have any ideas on where the TypeConverter code is located?

https://github.com/dotnet/winforms/blob/4f4829de9a3b4c56496a60ec18d774ca40956b53/src/System.Windows.Forms/src/System/Windows/Forms/PropertyGridInternal/ImmutablePropertyDescriptorGridEntry.cs#L47-L65

Read more comments on GitHub >

github_iconTop Results From Across the Web

How do I convert a powershell hashtable to an object?
Converting nested hashtables, i.e. an object graph, to a [pscustomobject] graph: A simple, though limited and potentially expensive solution is ...
Read more >
Convert `Hashtable` usage to `Dictionary<TKey, TValue`
Windows Forms is a .NET UI framework for building Windows desktop applications. - Convert `Hashtable` usage to `Dictionary.
Read more >
C# Hashtable (With Examples)
This tutorial explains Hashtable in C#. A hashtable stores key-value pairs. It retrieves the values by comparing the hash value of the keys....
Read more >
about Hash Tables - PowerShell
A hashtable, also known as a dictionary or associative array, is a compact data structure that stores one or more key-value pairs.
Read more >
Working with Hashtable and Dictionary in C
Determines whether the Hashtable contains a specific value. The following is an example showing the usage of Hashtable class in C# −. Example....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found