Articles on Trending Technologies

Technical articles with clear explanations and examples

How to move all the zeros to the end of the array from the given array of integer numbers using C#?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 17-Mar-2026 887 Views

Moving zeros to the end of an array is a common programming problem that can be solved efficiently using a two-pointer approach. The algorithm maintains the relative order of non-zero elements while shifting all zeros to the end of the array. Algorithm Overview The solution uses a single pass through the array with two pointers − Write Pointer − tracks the position where the next non-zero element should be placed Read Pointer − traverses through all elements in the array Time Complexity − O(N) where N is the array length Space Complexity − O(1) ...

Read More

Check if a SortedSet is a superset of the specified collection in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 221 Views

To check if a SortedSet is a superset of the specified collection in C#, we use the IsSupersetOf() method. A superset means that one set contains all the elements of another set, and possibly additional elements. Syntax Following is the syntax for the IsSupersetOf() method − public bool IsSupersetOf(IEnumerable other) Parameters other − The collection to compare with the current SortedSet. Return Value Returns true if the SortedSet contains all elements of the specified collection; otherwise, false. Superset Relationship ...

Read More

Get the hash code for this instance in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 339 Views

To get the hash code for this instance in C#, you use the GetHashCode() method. This method returns a hash code for the current object, which is useful for hash-based operations and collections like HashSet and Dictionary. Syntax Following is the syntax for getting the hash code of an instance − public virtual int GetHashCode() Return Value The GetHashCode() method returns a 32-bit signed integer that serves as the hash code for this instance. Objects that are equal should return the same hash code, though the reverse is not necessarily true. Using ...

Read More

How do I overload the [] operator in C#?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 17-Mar-2026 484 Views

The indexer ([] operator) in C# allows an object to be accessed like an array using square bracket notation. When you define an indexer for a class, instances of that class behave like virtual arrays, enabling array-style access using the [] operator. Indexers can be overloaded with different parameter types and counts. The parameters don't have to be integers — you can use strings, multiple parameters, or any other type as the index. Syntax Following is the basic syntax for defining an indexer − public returnType this[indexType index] { get { ...

Read More

How to check whether the given strings are isomorphic using C#?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 17-Mar-2026 1K+ Views

Two strings are called isomorphic if there exists a one-to-one character mapping between them. This means each character in the first string maps to exactly one character in the second string, and no two characters can map to the same character. The mapping must be consistent throughout both strings. For example, "egg" and "add" are isomorphic because 'e' maps to 'a', and 'g' maps to 'd'. However, "foo" and "bar" are not isomorphic because 'o' would need to map to both 'a' and 'r'. Algorithm Approach The solution uses two arrays to track the last seen position ...

Read More

Remove all elements of a List that match the conditions defined by the predicate in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 1K+ Views

The RemoveAll() method in C# removes all elements from a List that match the conditions defined by a predicate. A predicate is a method that takes an element as input and returns a boolean value indicating whether the element should be removed. Syntax Following is the syntax for the RemoveAll() method − public int RemoveAll(Predicate match) Parameters match − A predicate delegate that defines the conditions for removal. It takes an element of type T and returns true if the element should be removed. Return Value The method returns ...

Read More

Check if OrderedDictionary collection contains a specific key in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 279 Views

The OrderedDictionary collection in C# provides the Contains() method to check if a specific key exists in the collection. This method returns a boolean value − true if the key is found, false otherwise. Syntax Following is the syntax for checking if an OrderedDictionary contains a specific key − bool result = orderedDictionary.Contains(key); Parameters key − The key to locate in the OrderedDictionary collection. Return Value The method returns true if the OrderedDictionary contains an element with the specified key; otherwise, false. Using Contains() with Numeric Keys ...

Read More

How to Deserializing JSON to .NET object using Newtonsoft json in C# and pick only one value from the array?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 17-Mar-2026 729 Views

JSON deserialization is the process of converting JSON data into .NET objects. The Newtonsoft.Json library (also known as Json.NET) provides powerful methods to deserialize JSON strings into strongly-typed C# objects. When working with JSON arrays, you can easily pick specific values from the deserialized array. Syntax Following is the syntax for deserializing JSON to a .NET object − T obj = JsonConvert.DeserializeObject(jsonString); For deserializing JSON arrays − T[] objArray = JsonConvert.DeserializeObject(jsonString); Using WebClient to Fetch and Deserialize JSON The WebClient class provides methods for downloading data from web resources. ...

Read More

How to find the length of the longest substring from the given string without repeating the characters using C#?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 17-Mar-2026 1K+ Views

The longest substring without repeating characters problem can be efficiently solved using the sliding window technique with two pointers. This approach maintains a window of unique characters and expands or contracts it based on whether duplicates are found. Algorithm Overview The sliding window technique uses two pointers i (left) and j (right) to maintain a window of unique characters. When a duplicate character is encountered, the left pointer moves forward to exclude the duplicate, while the right pointer continues expanding the window. Sliding Window Technique ...

Read More

Check if two LinkedList objects are equal in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 270 Views

To check if two LinkedList objects are equal in C#, you need to understand that the Equals() method performs reference equality by default, not content equality. This means it only returns true if both references point to the same object instance. Understanding Reference vs Content Equality The LinkedList class inherits the default Equals() method from Object, which compares object references rather than the actual contents of the lists. LinkedList Equality Types Reference Equality list1.Equals(list2) Returns true only if both ...

Read More
Showing 9601–9610 of 61,299 articles
« Prev 1 959 960 961 962 963 6130 Next »
Advertisements