Server Side Programming Articles

Page 698 of 2109

BitConverter Class in C#

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

The BitConverter class in C# provides static methods to convert base data types to byte arrays and vice versa. It handles the conversion between different data types and their byte representations, making it essential for low-level data manipulation, file I/O, and network communication. Key Methods Method Description GetBytes(Boolean) Returns the specified Boolean value as a byte array. GetBytes(Char) Returns the specified Unicode character value as an array of bytes. GetBytes(Double) Returns the specified double-precision floating-point value as an array of bytes. GetBytes(Int32) Returns the specified ...

Read More

Check if a HashSet and a specified collection share common element in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 194 Views

To check if a HashSet and a specified collection share a common element, we use the Overlaps() method in C#. This method returns true if the HashSet shares at least one element with the specified collection, and false otherwise. Syntax Following is the syntax for the Overlaps() method − public bool Overlaps(IEnumerable other) Parameters other − The collection to compare with the current HashSet. Return Value Returns true if the HashSet and the specified collection share at least one common element; otherwise, false. Using Overlaps() with Integer HashSets ...

Read More

Check if a value is in LinkedList in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 166 Views

To check if a value exists in a LinkedList in C#, you can use the Contains() method. This method performs a linear search through the linked list and returns true if the specified value is found, or false otherwise. Syntax Following is the syntax for the Contains() method − public bool Contains(T item) Parameters item − The value to locate in the LinkedList. Return Value Returns true if the item is found in the LinkedList; otherwise, false. LinkedList.Contains() Method ...

Read More

Check if an array contains the elements that match the specified conditions in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 515 Views

To check if an array contains elements that match specific conditions in C#, we can use the Array.Exists() method. This method returns true if at least one element in the array matches the specified condition, and false otherwise. Syntax Following is the syntax for Array.Exists() method − public static bool Exists(T[] array, Predicate match); Parameters array − The one-dimensional array to search. match − The predicate that defines the conditions of the elements to search for. Return Value Returns true if at least one element ...

Read More

Check if an Array has fixed size or not in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 216 Views

In C#, all arrays have a fixed size once they are created. You cannot change the length of an array after initialization. To check if an array has a fixed size, use the IsFixedSize property, which always returns true for arrays. Syntax Following is the syntax to check if an array has fixed size − bool isFixed = arrayName.IsFixedSize; Using IsFixedSize Property Example using System; public class Demo { public static void Main() { string[] products = new ...

Read More

Removing all entries from the StringDictionary in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 134 Views

The StringDictionary class in C# provides a collection of string key-value pairs. To remove all entries from a StringDictionary, you use the Clear() method, which empties the entire collection in a single operation. Syntax Following is the syntax for removing all entries from a StringDictionary − stringDictionary.Clear(); Parameters The Clear() method takes no parameters and returns void. It removes all key-value pairs from the StringDictionary and sets the Count property to zero. Using Clear() Method Example using System; using System.Collections; using System.Collections.Specialized; public class Demo { ...

Read More

Removing all nodes from LinkedList in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 252 Views

The LinkedList class in C# provides the Clear() method to remove all nodes from a LinkedList efficiently. This method removes all elements and sets the Count property to zero. Syntax Following is the syntax for the Clear() method − public void Clear() Parameters The Clear() method does not take any parameters. Return Value The Clear() method does not return any value. It modifies the LinkedList by removing all nodes. Using Clear() with Integer LinkedList The following example demonstrates how to remove all nodes from a LinkedList containing integers − ...

Read More

Get an enumerator that iterates through StringCollection in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 205 Views

The StringCollection class in C# provides a GetEnumerator() method that returns a StringEnumerator object. This enumerator allows you to iterate through the collection elements one by one using the MoveNext() and Current properties. Syntax Following is the syntax for getting an enumerator from StringCollection − StringEnumerator enumerator = stringCollection.GetEnumerator(); Following is the syntax for iterating using the enumerator − while (enumerator.MoveNext()) { Console.WriteLine(enumerator.Current); } Using GetEnumerator() with StringCollection The GetEnumerator() method returns a StringEnumerator that provides MoveNext() and Current members for manual iteration − Example ...

Read More

Get an enumerator that iterates through the Dictionary in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 604 Views

To get an enumerator that iterates through a Dictionary in C#, you use the GetEnumerator() method which returns an IDictionaryEnumerator. This enumerator provides access to both keys and values as you iterate through the dictionary's key-value pairs. Syntax Following is the syntax for getting a Dictionary enumerator − IDictionaryEnumerator enumerator = dictionary.GetEnumerator(); The enumerator is used with MoveNext() to advance through the collection − while (enumerator.MoveNext()) { Console.WriteLine("Key = " + enumerator.Key + ", Value = " + enumerator.Value); } Using Dictionary Enumerator with Integer Keys ...

Read More

Check if an array is read-only or not in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 316 Views

In C#, arrays are typically mutable by default, meaning their elements can be modified after creation. However, you can check if an array is read-only using the IsReadOnly property from the ICollection interface. The IsReadOnly property returns true if the array cannot be modified, and false if elements can be changed. Regular arrays in C# always return false for this property. Syntax Following is the syntax to check if an array is read-only − bool isReadOnly = arrayName.IsReadOnly; Using IsReadOnly Property Example The following example demonstrates how to check if an ...

Read More
Showing 6971–6980 of 21,090 articles
« Prev 1 696 697 698 699 700 2109 Next »
Advertisements