Found 33676 Articles for Programming

How to Delete Item from Hashtable Collection in C#?

Shilpa Nadkarni
Updated on 14-Dec-2022 14:01:31

498 Views

The Hashtable in C# is a collection of key−value pairs that are organized based on the hash code of the key. The items in the hashtable are accessed using a key. The Hashtable class of C# is the class that implements the hashtable. Using this class, we can create a new hashtable object with the help of the constructors provided. The Hashtable class also provides various methods using which we can perform various operations on the hashtable. These operations include adding items, checking for the existence of specified keys, counting the number of items, removing an item from the hashtable, ... Read More

How to Create a HashTable Collection in C#?

Shilpa Nadkarni
Updated on 14-Dec-2022 11:49:16

233 Views

The HashTable is a non−generic collection in C#. It stores key-value pairs and is similar to a generic “Dictionary” collection. HashTable is defined in System. Collections. namespace. HashTable computes the hash code of each key and stores it in a different bucket internally. The hash code is then matched to the hash code of the specified key when the values are accessed. Thus the lookups are optimized by HashTable. In this tutorial, we will see how we can create a HashTable collection in C#. Hashtable Features Before we jump to creating a HashTable, let us see some of ... Read More

Haskell Program to Find the Area of a Square

Potti Chandra Sekhar sai
Updated on 14-Dec-2022 11:53:01

510 Views

This tutorial discusses writing a program to print the area of a square in the Haskell programming language. The square is a quadrilateral with all sides of the same length. The area of a square is equal to the square of the size of the side. If the side of the square has a size of 5 units, then the area of that is 25 units(5*5). In this tutorial, We see four ways to implement. Program to compute the area of a square using the infix operator “*”. Program to compute the area of a square using the ... Read More

How to Check if a Key Exists in the Hashtable in C#?

Shilpa Nadkarni
Updated on 14-Dec-2022 11:47:21

2K+ Views

The Hashtable class in C# represents a collection of key-value pairs. These key-value pairs are organized based on the hash code of the key that is calculated using the hash code function. The key in the hashtable accesses the items. So given a key, we can access the corresponding value for that key in the hashtable. The keys in the hashtable are unique and non-null. The values however can be null or duplicated. We have been discussing hashtable topics in our earlier tutorials. We continue the trend in this article as well. In this article, we will discuss how to ... Read More

Haskell Program to Calculate the Power of a Number

Potti Chandra Sekhar sai
Updated on 14-Dec-2022 11:41:06

1K+ Views

This tutorial discusses writing a program to calculate the power of a number in the Haskell programming language. The nth power of a number is the value when the number is multiplied by itself n times. The power of numbers can be expressed in exponential forms “a^n”, a is raised to the power of n. Here a is called the base and n is called an exponent. For example, 2 raised to the power of 5 is 2^5 i.e 32. In this tutorial, we see different ways to implement a program to calculate the power of a number. Program ... Read More

How to Add Items to Hashtable Collection in C#

Shilpa Nadkarni
Updated on 14-Dec-2022 11:40:06

794 Views

We have already discussed the basics of hashtables. A hashtable collection in C# is used to store key−value pairs wherein each of these key-value pairs is organized based on the hash code of the key. This hash code is calculated using a hash code function. Internally, the hashtable uses buckets to store data. A bucket is nothing but a virtual group of elements within the hashtable. A hash code is associated with each bucket. Programmatically, a hashtable is similar to a dictionary object but unlike in dictionary object, a hashtable can store objects of different data types. Performance−wise, hashtables exhibit ... Read More

Haskell Program to Find the Surface area and Volume of Cuboid

Potti Chandra Sekhar sai
Updated on 14-Dec-2022 11:36:41

284 Views

This tutorial discusses writing a program to find the Surface area and volume of a cuboid in the Haskell programming language. A cuboid is a solid shape that has six rectangular faces. A cuboid has three dimensions length, breadth, and height. The surface area of a cuboid is the total area of the six rectangular faces i.e 2*length*breadth + 2*length*height + 2*breadth*height. The volume of the cuboid is length*breadth*height. As volume is area*height. In this tutorial we see, Program to find the surface area of a cuboid. Program to find the volume of a cuboid. Algorithm Steps ... Read More

Haskell Program to Count Number of Digits in an Integer

Potti Chandra Sekhar sai
Updated on 14-Dec-2022 11:33:52

1K+ Views

In this tutorial, we discuss writing a program to count the number of digits in an integer in the Haskell programming language. In this tutorial, we see three ways to implement a program to count digits in Haskell. Program to count the number of digits in an integer. Program to count the number of digits in an integer using if-else.Program to count the number of digits in an integer using the length function. Algorithmic Steps Take input or initialize a variable for an integer. Implement the program logic to count the digits in an integer. Print or display ... Read More

Haskell Program to Reverse a Number

Potti Chandra Sekhar sai
Updated on 14-Dec-2022 11:30:06

821 Views

This tutorial discusses writing a program to reverse a number in the Haskell programming language. In this tutorial, we see two ways to implement a program in Haskell to reverse a number. Program to reverse a number using the list function reverse. Program to reverse a number using a recursive function. Example 1 Program to reverse a number using the list function reverse. -- function declaration reverseNumber :: Int->Int -- function definition reverseNumber n = k where temp = reverse (show n) ... Read More

Haskell Program to Find the Area of a parallelogram

Potti Chandra Sekhar sai
Updated on 14-Dec-2022 11:22:32

259 Views

This tutorial discusses writing a program to print the area of a parallelogram in the Haskell programming language. A parallelogram is a quadrilateral with opposite sides that have the same size and are parallel to each other. In this tutorial, We see three ways to implement Program to compute the area of a parallelogram using height and base. Program to compute the area of a parallelogram using sides. Program to compute the area of a parallelogram using the diagonals. Algorithm Steps Take input or initialize the variable for the size of the parallelogram. Implement the program ... Read More

Advertisements