Articles on Trending Technologies

Technical articles with clear explanations and examples

Tutorix - AI Tutor

C# Program to Return Quadrant in which the Coordinate Lie

AYUSH MISHRA
AYUSH MISHRA
Updated on 17-Mar-2026 4K+ Views

The Cartesian coordinate system is divided into four quadrants based on the signs of x and y coordinates. In this article, we will learn how to determine which quadrant a given point lies in using C#. Understanding Quadrants The coordinate plane is divided into four regions called quadrants − Quadrant I: x > 0 and y > 0 (both positive) Quadrant II: x < 0 and y > 0 (x negative, y positive) Quadrant III: x < 0 and y < 0 (both negative) Quadrant IV: x > 0 and y < 0 (x positive, y ...

Read More

How to delete all files and folders from a path in C#?

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

Deleting all files and folders from a directory is a common task in C# file operations. The System.IO namespace provides the DirectoryInfo class and Directory class that offer multiple approaches to accomplish this task safely and efficiently. Syntax Following is the syntax for using DirectoryInfo to delete directories and files − DirectoryInfo di = new DirectoryInfo(path); di.Delete(true); // true = recursive delete Following is the syntax for using Directory class methods − Directory.Delete(path, true); // true = recursive delete Using DirectoryInfo for Recursive Deletion The DirectoryInfo class provides detailed ...

Read More

Remove entry with specified key from OrderedDictionary in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 220 Views

The OrderedDictionary class in C# provides the Remove() method to remove entries with a specified key. The OrderedDictionary maintains the insertion order of elements while allowing both key-based and index-based access. Syntax Following is the syntax for removing an entry by key from an OrderedDictionary − orderedDictionary.Remove(key); Parameters key − The key of the entry to remove from the OrderedDictionary. Return Value The Remove() method does not return a value. It removes the entry if the key exists, or does nothing if the key is not found. ...

Read More

How to create a shallow copy of SortedList Object in C#?

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 286 Views

The shallow copy of a SortedList object in C# creates a new SortedList instance with the same key-value pairs as the original, but both collections share references to the same objects. This is accomplished using the Clone() method. Syntax Following is the syntax for creating a shallow copy of SortedList − SortedList clonedList = (SortedList)originalList.Clone(); What is a Shallow Copy? A shallow copy creates a new collection object, but the elements inside both the original and copied collections point to the same memory locations. For value types like strings and integers, this behaves ...

Read More

What is the main difference between int.Parse() and Convert.ToInt32 in C#?

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

Both int.Parse() and Convert.ToInt32() methods in C# are used to convert string representations of numbers to integers. However, they handle null values and certain edge cases differently. The key difference is that Convert.ToInt32() handles null values gracefully by returning 0, while int.Parse() throws an ArgumentNullException when encountering null. Syntax Following is the syntax for int.Parse() method − int result = int.Parse(stringValue); Following is the syntax for Convert.ToInt32() method − int result = Convert.ToInt32(stringValue); Using int.Parse() with Valid String The int.Parse() method converts a valid numeric string to an ...

Read More

Remove entry with specified key from the StringDictionary in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 171 Views

The StringDictionary class in C# provides the Remove() method to delete entries with a specified key. This method removes both the key and its associated value from the collection. StringDictionary is case-insensitive, meaning keys are automatically converted to lowercase. Syntax Following is the syntax for the Remove() method − public virtual void Remove(string key) Parameters key − The string key to remove from the StringDictionary. Using Remove() Method Example using System; using System.Collections; using System.Collections.Specialized; public class Demo { public static void Main() ...

Read More

How to get hash code for the specified key of a Hashtable in C#?

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 331 Views

To get the hash code for a specified key in a Hashtable, you need to use the GetHash() method. This method is protected in the base Hashtable class, so you must create a derived class to access it. The hash code is an integer value used internally by the hashtable to determine where to store the key-value pair. Syntax Following is the syntax to access the protected GetHash() method − public class CustomHashtable : Hashtable { public int GetHashCodeForKey(object key) { return GetHash(key); } ...

Read More

How can we update the values of a collection using LINQ in C#?

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

LINQ provides several approaches to update collection values in C#. While LINQ is primarily designed for querying data, you can combine it with other methods to modify collection elements efficiently. Using ForEach with List Collections The List class provides a ForEach method that can be used to update all elements in the collection − using System; using System.Collections.Generic; namespace DemoApplication { class Program { static void Main(string[] args) { List fruits ...

Read More

Remove from the specified index of a SortedList in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 247 Views

The SortedList class in C# provides the RemoveAt() method to remove a key-value pair from a specified index. The RemoveAt() method removes the element at the specified zero-based index and automatically shifts the remaining elements to fill the gap. Syntax Following is the syntax for the RemoveAt() method − public virtual void RemoveAt(int index) Parameters index − The zero-based index of the element to remove. Key Points The index is zero-based, meaning the first element is at index 0. After removal, all elements at higher indices are shifted ...

Read More

How to create a StringCollection in C#?

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 193 Views

The StringCollection class in C# is a specialized collection that stores only string values. It is part of the System.Collections.Specialized namespace and provides methods to add, remove, and manipulate strings efficiently. StringCollection is useful when you need to work exclusively with string data and want type safety without the overhead of generic collections. Syntax Following is the syntax for creating a StringCollection − StringCollection collection = new StringCollection(); To add multiple strings at once using an array − string[] array = {"string1", "string2", "string3"}; collection.AddRange(array); Creating and Populating a ...

Read More
Showing 9721–9730 of 61,297 articles
« Prev 1 971 972 973 974 975 6130 Next »
Advertisements