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
Server Side Programming Articles
Page 694 of 2109
C# SortedDictionary.Add() Method
The SortedDictionary.Add() method in C# is used to add an element with the specified key and value into the SortedDictionary. Unlike regular dictionaries, SortedDictionary maintains elements in sorted order based on the keys. Syntax Following is the syntax for the Add() method − public void Add(TKey key, TValue value); Parameters key − The key of the element to add. Cannot be null. value − The value of the element to add. Can be null if TValue is a reference type. Return Value This method does not return a value. ...
Read MoreSortedDictionary.Clear() Method in C#
The SortedDictionary.Clear() method in C# is used to remove all key-value pairs from the SortedDictionary. This method provides an efficient way to empty the entire collection in a single operation. Syntax Following is the syntax for the Clear() − public void Clear(); Parameters This method takes no parameters. Return Value This method does not return any value (void). Using Clear() Method with Electronic Items The following example demonstrates how Clear() removes all items from the SortedDictionary − using System; using System.Collections.Generic; public class Demo { ...
Read MoreDouble.IsInfinity() Method in C#
The Double.IsInfinity() method in C# is used to determine whether a double-precision floating-point number represents positive or negative infinity. This method returns true if the specified number evaluates to either PositiveInfinity or NegativeInfinity, and false otherwise. Infinity values in C# occur when mathematical operations exceed the range of double values, such as dividing a non-zero number by zero or performing calculations that result in overflow. Syntax Following is the syntax for the Double.IsInfinity() method − public static bool IsInfinity(double d); Parameters d − A double-precision floating-point number to test for infinity. ...
Read MoreTimeSpan.Add() Method in C#
The TimeSpan.Add() method in C# returns a new TimeSpan object whose value is the sum of the specified TimeSpan object and the current instance. This method is useful for adding time intervals together, such as combining durations or calculating elapsed time periods. Syntax Following is the syntax for the TimeSpan.Add() method − public TimeSpan Add(TimeSpan span); Parameters span − A TimeSpan object representing the time interval to add to the current TimeSpan instance. Return Value Returns a new TimeSpan object that represents the sum of the current TimeSpan and the specified ...
Read MoreTimeSpan.Compare() Method in C#
The TimeSpan.Compare() method in C# is a static method used to compare two TimeSpan values and returns an integer that indicates their relative relationship. This method is useful for sorting operations and determining the order of time intervals. Syntax Following is the syntax for the TimeSpan.Compare() method − public static int Compare(TimeSpan span1, TimeSpan span2); Parameters span1 − The first TimeSpan value to compare. span2 − The second TimeSpan value to compare. Return Value The method returns an integer with the following meaning − Return ...
Read MoreSortedDictionary.ContainsValue() Method in C#
The SortedDictionary.ContainsValue() method in C# is used to determine whether the SortedDictionary contains an element with the specified value. This method performs a linear search through all values in the collection. Syntax Following is the syntax of the ContainsValue() method − public bool ContainsValue(TValue value) Parameters value − The value to be searched in the SortedDictionary. The value can be null for reference types. Return Value Returns true if the SortedDictionary contains an element with the specified value; otherwise, false. Using ContainsValue() to Check Existing Values The following example ...
Read MoreQueue.Enqueue() Method in C#
The Queue.Enqueue() method in C# is used to add an object to the end of the Queue. This method follows the FIFO (First In, First Out) principle where elements are added at the rear and removed from the front. Syntax For generic Queue collections − public void Enqueue(T item); For non-generic Queue collections − public virtual void Enqueue(object obj); Parameters item/obj − The object to add to the end of the Queue. The value can be null for reference types. Queue.Enqueue() Operation ...
Read MoreQueue.Equals() Method in C#
The Queue.Equals() method in C# is used to determine whether the specified object is equal to the current queue instance. This method performs reference equality comparison, not content comparison, meaning it returns true only if both variables refer to the same queue object in memory. Syntax Following is the syntax for the Queue.Equals() method − public virtual bool Equals(object obj); Parameters obj − The object to compare with the current queue instance. Return Value Returns true if the specified object is the same instance as the current queue; otherwise, ...
Read MoreStack.Clone() Method in C#
The Stack.Clone() method in C# creates a shallow copy of the Stack. This method returns a new Stack object with the same elements as the original, but both stacks remain independent for basic operations like Push and Pop. Syntax Following is the syntax for the Stack.Clone() method − public virtual object Clone(); Return Value The method returns an object that represents a shallow copy of the Stack. You need to cast it back to a Stack type to use it as a Stack. Understanding Shallow Copy A shallow copy means that ...
Read MoreQueue.Synchronized() Method in C#
The Queue.Synchronized() method in C# returns a thread-safe wrapper around an existing Queue object. This method is part of the System.Collections namespace and provides synchronization for multi-threaded applications where multiple threads need to access the same queue safely. Syntax Following is the syntax for the Queue.Synchronized() method − public static System.Collections.Queue Synchronized(System.Collections.Queue queue); Parameters The method accepts one parameter − queue − The Queue object to be wrapped with synchronization. Return Value Returns a synchronized (thread-safe) wrapper for the specified Queue. The wrapper provides synchronized access to all ...
Read More