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 696 of 2109
SortedDictionary.Keys Property in C#
The SortedDictionary.Keys property in C# returns a collection containing all the keys in the SortedDictionary. The keys are returned in sorted order based on the comparer used by the SortedDictionary. Syntax Following is the syntax for the Keys property − public SortedDictionary.KeyCollection Keys { get; } Return Value The Keys property returns a SortedDictionary.KeyCollection containing all the keys in the SortedDictionary. The collection is read-only and reflects changes made to the underlying dictionary. Using Keys Property with Integer Keys Example using System; using System.Collections.Generic; public class Demo { ...
Read MoreSortedDictionary.Remove() Method in C#
The SortedDictionary.Remove() method in C# is used to remove the element with the specified key from the SortedDictionary. This method returns a bool value indicating whether the removal was successful. Syntax Following is the syntax for the Remove() method − public bool Remove (TKey key); Parameters key − The key of the element to remove from the SortedDictionary. Return Value The method returns true if the element is successfully found and removed; otherwise, false. This method also returns false if the key is not found in the original SortedDictionary. ...
Read MoreRandom.NextDouble() Method in C#
The Random.NextDouble() method in C# generates a random floating-point number that is greater than or equal to 0.0 and less than 1.0. This method is useful for generating decimal probabilities, percentages, or scaling random values to specific ranges. Syntax Following is the syntax for the NextDouble() method − public virtual double NextDouble(); Return Value The method returns a double value in the range [0.0, 1.0), where 0.0 is inclusive and 1.0 is exclusive. Using NextDouble() for Basic Random Numbers Example using System; public class Demo { ...
Read MoreSingle.IsInfinity() Method in C# with Example
The Single.IsInfinity() method in C# is used to determine whether a single-precision floating-point number represents positive or negative infinity. This method is particularly useful when performing mathematical operations that might result in infinite values, such as division by zero. Syntax Following is the syntax for the Single.IsInfinity() method − public static bool IsInfinity(float val); Parameters val − A single-precision floating-point number to be tested for infinity. Return Value The method returns true if the specified value evaluates to positive or negative infinity; otherwise, false. Single.IsInfinity() Method ...
Read MoreQueue.GetEnumerator() Method in C#
The Queue.GetEnumerator() method in C# returns an IEnumerator object that allows you to iterate through the elements of a Queue in FIFO (First In, First Out) order. This method is essential for implementing custom iteration logic or using the Queue in foreach loops. Syntax Following is the syntax for the GetEnumerator() method − public virtual System.Collections.IEnumerator GetEnumerator(); Return Value The method returns an IEnumerator object that can iterate through the Queue elements from the front to the rear. Using GetEnumerator() with While Loop The most common way to use GetEnumerator() is ...
Read MoreRandom.NextBytes() Method in C#
The Random.NextBytes() method in C# is used to fill the elements of a specified byte array with random numbers. Each element in the array receives a random value between 0 and 255 (the range of a byte). Syntax Following is the syntax for the NextBytes() method − public virtual void NextBytes(byte[] buffer); Parameters buffer − An array of bytes to be filled with random numbers. The array must be initialized before calling this method. Return Value This method does not return a value. It modifies the passed byte array ...
Read MoreInt64.ToString() Method in C#
The Int64.ToString() method in C# is used to convert a 64-bit integer (long) value to its equivalent string representation. This method provides multiple overloads for different formatting options, allowing you to control how the numeric value appears as text. Syntax Following are the primary syntax overloads for the Int64.ToString() method − public override string ToString(); public string ToString(string format); public string ToString(IFormatProvider provider); public string ToString(string format, IFormatProvider provider); Parameters format − A numeric format string that specifies how the value should be formatted (optional). provider − An object that supplies culture-specific ...
Read MoreBoolean.GetTypeCode() Method in C# with Examples
The Boolean.GetTypeCode() method in C# is used to return the type code for the Boolean value type. This method returns TypeCode.Boolean, which is part of the TypeCode enumeration that represents different data types in the .NET framework. Syntax Following is the syntax for the Boolean.GetTypeCode() method − public TypeCode GetTypeCode(); Return Value This method returns TypeCode.Boolean, which represents the Boolean data type in the TypeCode enumeration. Using GetTypeCode() with Boolean Values Example using System; public class Demo { public static void Main(String[] args) { ...
Read MoreSortedDictionary.Values Property in C#
The SortedDictionary.Values property in C# is used to get a collection containing the values in the SortedDictionary. This property returns a ValueCollection that preserves the sorted order of the original dictionary based on the keys. Syntax Following is the syntax for the Values property − public SortedDictionary.ValueCollection Values { get; } Return Value The property returns a SortedDictionary.ValueCollection containing all the values in the sorted dictionary. The values maintain the same order as their corresponding keys in the sorted dictionary. Using Values Property to Iterate Through Values The following example demonstrates ...
Read MoreRandom.Next() Method in C#
The Random.Next() method in C# is used to generate non-negative random integers. It provides multiple overloads to control the range of generated numbers, making it useful for various scenarios like games, simulations, and testing. Syntax The Random.Next() method has three overloads − public virtual int Next(); public virtual int Next(int maxValue); public virtual int Next(int minValue, int maxValue); Parameters maxValue − The exclusive upper bound of the random number (0 to maxValue-1). minValue − The inclusive lower bound of the random number. maxValue − The exclusive upper bound of the random number ...
Read More