Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Articles on Trending Technologies
Technical articles with clear explanations and examples
Uri.IsBaseOf(Uri) Method in C#
The Uri.IsBaseOf() method in C# is used to determine whether the current Uri instance is a base of the specified Uri instance. This method is particularly useful when working with URL hierarchies and checking if one URI is a parent or base path of another URI. Syntax Following is the syntax − public bool IsBaseOf(Uri uri); Parameters uri − The specified Uri instance to test against the current Uri instance. Return Value Returns true if the current Uri instance is a base of the specified Uri; otherwise, false. ...
Read MoreC# String Operators
C# provides several string operators that allow you to perform operations and comparisons on strings. The primary string operators include equality (==), inequality (!=), and the concatenation operator (+). These operators make string manipulation and comparison straightforward and intuitive. Syntax Following is the syntax for string comparison operators − bool result = string1 == string2; // Equality bool result = string1 != string2; // Inequality string result = string1 + string2; // Concatenation String Equality Operator (==) The equality operator checks if two strings have the same content. It performs a ...
Read MoreRemove all objects from the Stack in C#
In C#, the Stack class provides the Clear() method to remove all objects from the Stack. This method efficiently removes every element from the Stack, leaving it empty with a count of zero. Syntax Following is the syntax for removing all objects from a Stack − stack.Clear(); Where stack is the instance of the Stack from which all elements need to be removed. How It Works The Clear()
Read MoreHow to find the number of times array is rotated in the sorted array by recursion using C#?
To find the number of times a sorted array has been rotated, we need to locate the position of the minimum element. The number of rotations equals the index of the minimum element. We can solve this efficiently using binary search recursion. In a rotated sorted array, the minimum element is the pivot point where the rotation occurred. For example, in array [4, 5, 6, 1, 2, 3], the minimum element 1 is at index 3, meaning the array was rotated 3 times. Algorithm The recursive binary search approach works as follows − Find ...
Read MoreC# BitConverter.ToUInt32() Method
The BitConverter.ToUInt32() method in C# converts four consecutive bytes from a byte array into a 32-bit unsigned integer. This method reads bytes in little-endian format, where the least significant byte comes first. Syntax public static uint ToUInt32(byte[] value, int startIndex); Parameters value − The byte array containing the data to convert. startIndex − The starting position within the byte array (must be between 0 and array length minus 4). Return Value Returns a 32-bit unsigned integer (uint) formed by four bytes beginning at startIndex. Little-Endian ...
Read MoreRemoving all entries from HybridDictionary in C#
A HybridDictionary in C# is part of the System.Collections.Specialized namespace that automatically switches between a ListDictionary and Hashtable based on the number of elements. To remove all entries from a HybridDictionary, you use the Clear() method. Syntax Following is the syntax for removing all entries from a HybridDictionary − hybridDictionary.Clear(); Using Clear() Method The Clear() method removes all key-value pairs from the HybridDictionary and sets the Count property to zero − Example using System; using System.Collections; using System.Collections.Specialized; public class Demo { public static void Main() ...
Read MoreGetting an enumerator for the entire ArrayList in C#?
To get an enumerator for the entire ArrayList in C#, you use the GetEnumerator() method. This method returns an IEnumerator object that allows you to iterate through all elements in the ArrayList sequentially. An enumerator is a read-only, forward-only iterator that provides access to each element in a collection. Unlike a foreach loop, using an enumerator gives you explicit control over the iteration process. Syntax Following is the syntax for getting an enumerator for an ArrayList − IEnumerator enumerator = arrayList.GetEnumerator(); while (enumerator.MoveNext()) { Console.WriteLine(enumerator.Current); } Using GetEnumerator() with ...
Read MoreC# Program to Search Sub-Directory in a Given Directory
Searching for sub-directories in a given directory is a common task in many applications. In C#, we can use the Directory and DirectoryInfo classes provided by the System.IO namespace to perform this task. In this article, we will explore how to write a C# program to search for sub-directories in a given directory. Syntax Following is the syntax for using DirectoryInfo.GetDirectories() method − DirectoryInfo directoryInfo = new DirectoryInfo(path); DirectoryInfo[] subdirectories = directoryInfo.GetDirectories(); Following is the syntax for using Directory.GetDirectories() method − string[] subdirectories = Directory.GetDirectories(path); Using DirectoryInfo.GetDirectories() The DirectoryInfo.GetDirectories() ...
Read MoreC# BitConverter.ToUInt64 Method
The BitConverter.ToUInt64() method in C# converts eight consecutive bytes from a byte array into a 64-bit unsigned integer (ulong). This method is useful when you need to reconstruct numeric values from byte data, such as reading from binary files or network streams. Syntax public static ulong ToUInt64(byte[] value, int startIndex); Parameters value − The byte array containing the bytes to convert. startIndex − The starting position within the byte array (must have at least 8 bytes from this position). Return Value Returns a 64-bit unsigned integer (ulong) formed by eight ...
Read MoreGet an enumerator that iterates through the Hashtable in C#
To get an enumerator that iterates through the Hashtable in C#, you use the GetEnumerator() method. This method returns an IDictionaryEnumerator that provides key-value pair access to the hashtable elements. Syntax Following is the syntax for getting an enumerator from a Hashtable − IDictionaryEnumerator enumerator = hashtable.GetEnumerator(); The enumerator provides the following key members − enumerator.MoveNext() // advances to next element, returns bool enumerator.Key // gets current key enumerator.Value // gets current value enumerator.Entry ...
Read More