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[]
- IOException: The process cannot access the file ‘file path’ because it is being used by another process
- No connection could be made because the target machine actively refused it?
- What does a lock statement do under the hood?
- Converting string to byte array in C#
- Could not load file or assembly or one of its dependencies
- What is the purpose of nameof?
- Where/how can I download (and install) the Microsoft.Jet.OLEDB.4.0 for Windows 8, 64 bit?
- Convert Enum to String
- 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(){}
- Access to the path is denied
- Extension methods must be defined in a non-generic static class
- Metadata file ‘.dll’ could not be found
- Add new item in existing array in c#.net
- How to resolve this System.IO.FileNotFoundException
- What’s the difference between struct and class in .NET?
- How do I declare a DefaultValue attribute whose value is an array of strings?
- Where Is Machine.Config?
- HttpWebRequest-The remote server returned an error: (400) Bad Request
- “An attempt was made to load a program with an incorrect format” even when the platforms are the same
- Reading settings from app.config or web.config in .NET
- Invalid URI: The format of the URI could not be determined
- Multiple file-extensions searchPattern for System.IO.Directory.GetFiles
- 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
- How to add comments into a Xaml file in WPF?
- Why did I get the compile error “Use of unassigned local variable”?
- Reading CSV file and storing values into an array
- The remote server returned an error: (407) Proxy Authentication Required
- HashSet vs. List performance
- How to access Session variables and set them in javascript?
- How do I restart my C# WinForm Application?
- How to split() a delimited string to a List
- Remove element of a regular array
- Best way to reverse a string
- How can I know if a process is running?
- What is the purpose ApplicationDbContext Class in (under IdentityModels.cs file) ASP.NET MVC 5?
- How to solve “Could not establish trust relationship for the SSL/TLS secure channel with authority”
- windows could not start service on local computer error 5 access is denied
- Cannot attach the file *.mdf as database
- How to convert UTF-8 byte[] to string
- .NET String.Format() to add commas in thousands place for a number
- How can I download a file with batch file without using any external tools?
- Produce a random number in a range using C#
- How do I concatenate two arrays in C#?
- How to play a sound in C#, .NET
- Which passwordchar shows a black dot (•) in a winforms textbox?
- How do I fix a .NET windows application crashing at startup with Exception code: 0xE0434352?
- How to resolve file being used by another process?
- .NET Framework 4.6 or a later update is already installed on this computer
- c# .net change label text
- Retrieving the COM class factory for component with CLSID {XXXX} failed due to the following error: 80040154
- How to avoid a System.Runtime.InteropServices.COMException?
- How do I find the PublicKeyToken for a particular dll?
- Consider app.config remapping of assembly with no app.config mapping
- What is a “first chance exception”?
- How can I generate random alphanumeric strings?
- How do you do a deep copy of an object in .NET?
- .NET Core vs Mono
- A certificate chain could not be built to a trusted root authority
- Linq: GroupBy, Sum and Count
- How to enumerate an enum