Q:
What is a Hashtable in C#?
belongs to collection: C# Interview Questions and Answers,You Need To Know
C# Interview Questions and Answers,You Need To Know
- What is C#?
- What is an object in c#?
- What are C# attributes and their significance?
- What is the meaning of instantiation in c#?
- How will you differentiate between a Class and a Struct in c#?
- What is the difference between public, static, and void in c#?
- What’s a multicast delegate in c#?
- How do I calculate someone’s age in C#?
- What is the difference between public static, public and static methods in c#?
- What is a Virtual Method in C#?
- List down the fundamental OOP concepts in c#?
- Compare Virtual methods and Abstract methods in c#
- What are Namespaces in C#?
- Is every abstract function virtual in C#, in general?
- What are I/O classes in C#? Define some of the most commonly used ones
- What is the difference between SessionState and ViewState in c#?
- What’s the difference between a method and a function in c#?
- What is the difference between an abstract function and a virtual function in c#?
- What is an interface class? Give one example of it
- What is the advantage of interface class?
- Explain the process of inheriting a class into another class?
- What is the difference between an interface and abstract class?
- What are circular references?
- What is the advantage of abstract class?
- What happens if the inherited interfaces have conflicting method names?
- What is Constructor in C#?
- Explain some points related to the constructor?
- What is difference between “is” and “as” operators in c#?
- Why can’t you specify the accessibility modifier for methods inside the interface?
- What are Value types and Reference types in C#?
- What are Jagged Arrays in c#?
- Is elements of jagged array must be initialized before its use
- Why Doesn’t C# Allow Static Methods to Implement an Interface?
- What do you understand by regular expressions in C#? Write a program that searches a string using regular expressions
- What is the difference between ref & out parameters in c#?
- What is the difference between var and dynamic in C#
- What is the use of ‘using’ statement in C#?
- What is the major use of ‘using’ keyword in c#?
- What is the difference between String and string in C#?
- What is function overloading in c#?
- Explain some ways of doing overloading function in C#
- What is serialization?
- Explain Inheritance in C# with an example?
- What is the best way to give a C# auto-property an initial value?
- List down the reason behind the usage of C# language
- What are Custom Exceptions?
- What is Managed or Unmanaged Code in c#?
- Explain the features of C#?
- What is the difference between constant and readonly in C#?
- Can we use “this” command within a static method?
- Explain Deadlock?
- illustrate Race Condition?
- What is Thread Pooling?
- Distinguish between finally and finalize blocks?
- What is Boxing and Unboxing in C#?
- What is enum in C#?
- Describe Accessibility Modifiers in C#
- What is the difference between ‘protected’ and ‘protected internal’?
- How do short-circuited operators work?
- What is the “volatile” keyword used for?
- Why do we use Async and Await in C#?
- Explain different states of a thread in C#?
- What are delegates?
- What is the difference between “continue” and “break” statements in C#?
- What can you tell us about the XSD file in C#?
- What are Custom Control and User Control?
- What are sealed classes in C#?
- What is the difference between Array and Arraylist?
- Can a private virtual method can be overridden?
- What are Properties in C#?
- What are accessors?
- What are the differences between System.String and System.Text.StringBuilder classes?
- Why Properties are introduced in C#?
- What is the difference between the dispose and finalize methods in C#?
- What are partial classes?
- What’s the difference between the System.Array.CopyTo() and System.Array.Clone() ?
- What are the advantages of partial classes?
- What is the difference between late binding and early binding in C#?
- What are the differences between IEnumerable and IQueryable?
- What is Reflection in C#?
- Give an example of removing an element from the queue?
- What is the difference between directcast and ctype?
- How to implement a singleton design pattern in C#?
- What is the difference between the “throw” and “throw ex” in .NET?
- List down the commonly used types of exceptions in .net?
- How can we sort the elements of the Array in descending order?
- What is a Hashtable in C#?
- What is Multithreading with .NET?
A Hashtable is a collection that stores (Keys, Values) pairs. Here, the Keys are used to find the storage location and is immutable and cannot have duplicate entries in a Hashtable. The .Net Framework has provided a Hash Table class that contains all the functionality required to implement a hash table without any additional development. The hash table is a general-purpose dictionary collection. Each item within the collection is a DictionaryEntry object with two properties: a key object and a value object. These are known as Key/Value. When items are added to a hash table, a hash code is generated automatically. This code is hidden from the developer. Access to the table’s values is achieved using the key object for identification. As the items in the collection are sorted according to the hidden hash code, the items should be considered to be randomly ordered.
The Hashtable Collection:
The Base Class libraries offer a Hashtable Class that is defined in the System.Collections namespace, so you don’t have to code your own hash tables. It processes each key of the hash that you add every time and then uses the hash code to look up the element very quickly. The capacity of a hash table is the number of elements the hash table can hold. As elements are added to a hash table, the capacity is automatically increased as required through reallocation. It is an older .Net Framework type.
Declaring a Hashtable:
The Hashtable class is generally found in the namespace called System.Collections. So to execute any of the examples, we have to add using System.Collections; to the source code. The declaration for the Hashtable is:
need an explanation for this answer? contact us directly to get an explanation for this answer