For what it’s worth, a Dictionary is (conceptually) a hash table.
If you meant “why do we use the Dictionary<TKey, TValue>
class instead of the Hashtable
class?”, then it’s an easy answer: Dictionary<TKey, TValue>
is a generic type, Hashtable
is not. That means you get type safety with Dictionary<TKey, TValue>
, because you can’t insert any random object into it, and you don’t have to cast the values you take out.
Interestingly, the Dictionary<TKey, TValue>
implementation in the .NET Framework is based on the Hashtable
, as you can tell from this comment in its source code:
The generic Dictionary was copied from Hashtable’s source
Related Posts:
- How does the “Using” statement translate from C# to VB?
- When should I use a List vs a LinkedList
- What is a NullReferenceException, and how do I fix it?
- What is a NullReferenceException, and how do I fix it?
- What is a singleton in C#?
- My C# application is returning 0xE0434352 to Windows Task Scheduler but it is not crashing
- Priority queue in .Net
- C# Set collection?
- Windows Application has stopped working :: Event Name CLR20r3
- Does anyone still use [goto] in C# and if so why?
- What is the best way to parse html in C#? [closed]
- Best C# API to create PDF
- How do I create a Shared Code project (.shproj)
- C# cannot convert method to non delegate type
- What is the difference between const and readonly in C#?
- Pass Method as Parameter using C#
- Cannot access a disposed object – How to fix?
- Cannot access a disposed object – How to fix?
- ArrayList vs List<> in C#
- What’s the @ in front of a string in C#?
- How to solve ‘…is a ‘type’, which is not valid in the given context’? (C#)
- How should I cast in VB.NET?
- .NET graph library around?
- Calling the base constructor in C#
- Best way to repeat a character in C#
- How to empty a list in C#?
- How to open an Excel file in C#?
- What is a method group in C#?
- How do I save a stream to a file in C#?
- Print Pdf in C#
- Can a Byte[] Array be written to a file in C#?
- How to enable assembly bind failure logging (Fusion) in .NET
- Strip double quotes from a string in .NET
- What is the difference between String and string in C#?
- Creating a List of Lists in C#
- C# int to byte[]
- .Net 4.8 Support for Windows 10 ends in 26 days?
- How do I get a random YouTube video with the YouTube API?
- An existing connection was forcibly closed by the remote host
- How can I convert String to Int?
- I am getting Failed to load resource: net::ERR_BLOCKED_BY_CLIENT with Google chrome
- What’s the difference between .NET Core, .NET Framework, and Xamarin?
- IOException: The process cannot access the file ‘file path’ because it is being used by another process
- ‘Microsoft.ACE.OLEDB.12.0’ provider is not registered on the local machine
- How do I get my C# program to sleep for 50 msec?
- No connection could be made because the target machine actively refused it?
- Could not load file or assembly or one of its dependencies
- What does a lock statement do under the hood?
- Error : Could not load file or assembly or one of it’s dependencies
- Converting string to byte array in C#
- Could not load file or assembly or one of its dependencies
- What is WCF? and what can it do?
- What is the difference between int, Int16, Int32 and Int64?
- What is the purpose of nameof?
- Difference between Delphi and Delphi.NET
- How to open .dll files to see what is written inside?
- Where/how can I download (and install) the Microsoft.Jet.OLEDB.4.0 for Windows 8, 64 bit?
- Convert Enum to String
- Windows .NET API / Windows 7 / Bluetooth communication with Intel Curie Arduino / Genuino 101
- Error 1053 the service did not respond to the start or control request in a timely fashion
- Get current folder path
- foreach vs someList.ForEach(){}
- System.web.mvc missing
- Nullable object must have a value?
- Access to the path is denied
- What is the difference between ASP.NET MVC 6 and ASP.NET Core 1.0 and the reason behind the core framework?
- What does mscorlib stand for?
- Extension methods must be defined in a non-generic static class
- Metadata file ‘.dll’ could not be found
- WebForms UnobtrusiveValidationMode requires a ScriptResourceMapping for jquery
- “Error while trying to run project: Unable to start program”. Can run program only once. Then VS needs restart
- Add new item in existing array in c#.net
- How to resolve this System.IO.FileNotFoundException
- Embed a System.String in XAML
- What’s the difference between struct and class in .NET?
- What is clr.dll on .Net framework and what does it do?
- what is this oleaut32.dll?
- Associating enums with strings in C#
- How do I declare a DefaultValue attribute whose value is an array of strings?
- Where Is Machine.Config?
- How to resolve this System.IO.FileNotFoundException
- Why does .Net Socket.Disconnect take two minutes?
- HttpWebRequest-The remote server returned an error: (400) Bad Request
- Extension methods must be defined in a non-generic static class
- ClickOnce runtime DFSVC.EXE
- “An attempt was made to load a program with an incorrect format” even when the platforms are the same
- How to use the “Using” statement in ASP.net razor webpages?
- How can I get the application’s path in a .NET console application?
- Reading settings from app.config or web.config in .NET
- There is no argument given that corresponds to the required formal parameter – .NET Error
- How do I remedy “The breakpoint will not currently be hit. No symbols have been loaded for this document.” warning?
- SQL Connection Error: System.Data.SqlClient.SqlException (0x80131904)
- Tree data structure in C#
- Invalid URI: The format of the URI could not be determined
- Multiple file-extensions searchPattern for System.IO.Directory.GetFiles
- Could not establish trust relationship for SSL/TLS secure channel — SOAP
- Cannot send a content-body with this verb-type
- What is the C# version of VB.net’s InputDialog?
- Html.Partial vs Html.RenderPartial & Html.Action vs Html.RenderAction
- Unable to read data from the transport connection : An existing connection was forcibly closed by the remote host