Csharp Articles

Page 26 of 196

Stack.Synchronized() Method in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 154 Views

The Stack.Synchronized() method in C# returns a synchronized (thread-safe) wrapper for a Stack. This wrapper ensures that all operations on the stack are thread-safe, making it suitable for use in multi-threaded applications where multiple threads might access the same stack simultaneously. Syntax Following is the syntax for the Stack.Synchronized() method − public static System.Collections.Stack Synchronized(System.Collections.Stack stack); Parameters stack − The Stack object to synchronize. Return Value Returns a synchronized wrapper for the specified Stack. The returned wrapper provides thread-safe access to all Stack operations. Stack.Synchronized() Wrapper ...

Read More

Stack.ToString() Method in C# with examples

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

The Stack.ToString() method in C# is used to get the string representation of the Stack class object. This method returns the fully qualified type name of the stack instance, not the contents of the stack. To display stack elements, you need to iterate through the collection and call ToString() on individual elements. Syntax Following is the syntax for the Stack.ToString() method − public override string ToString(); Return Value This method returns a string that represents the current Stack object. It returns the type name "System.Collections.Stack". Using ToString() on Stack Elements The ...

Read More

SByte.CompareTo() Method in C# with Examples

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 130 Views

The SByte.CompareTo() method in C# is used to compare the current sbyte instance to a specified object or sbyte value and returns an integer that indicates their relative ordering. This method is essential for sorting operations and comparison logic. Syntax The SByte.CompareTo() method has two overloads − public int CompareTo(sbyte value); public int CompareTo(object obj); Parameters value − An 8-bit signed integer to compare with the current instance. obj − An object to compare with the current instance, or null. Return Value The method returns ...

Read More

Stack.Push() Method in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 784 Views

The Stack.Push() method in C# is used to insert an object at the top of the Stack. This method follows the Last In, First Out (LIFO) principle, where the most recently pushed element appears first when iterating through the stack. Syntax The syntax is as follows − public virtual void Push (object ob); Parameters ob − The object to push onto the stack. It can be null. Return Value This method does not return any value. It is a void method. Stack.Push() - LIFO Structure ...

Read More

SByte.Equals() Method in C# with Examples

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 127 Views

The SByte.Equals() method in C# is used to return a value indicating whether this instance is equal to a specified object or SByte. The sbyte data type represents an 8-bit signed integer with values ranging from -128 to 127. Syntax The SByte.Equals() method has two overloaded forms − public bool Equals(sbyte ob); public override bool Equals(object ob); Parameters ob (sbyte) − An SByte value to compare to this instance. ob (object) − An object to compare with this instance. Return Value Returns true if the ...

Read More

C# BitConverter.ToInt64() Method

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 339 Views

The BitConverter.ToInt64() method in C# is used to convert eight consecutive bytes from a byte array into a 64-bit signed integer (long). This method is particularly useful when working with binary data or when you need to reconstruct numeric values from byte representations. Syntax Following is the syntax for the BitConverter.ToInt64() method − public static long ToInt64(byte[] value, int startIndex); Parameters value − An array of bytes containing the eight bytes to convert. startIndex − The starting position within the byte array from which to begin the conversion. ...

Read More

Check if a SortedList object has a fixed size in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 182 Views

To check if a SortedList object has a fixed size in C#, you can use the IsFixedSize property. This property returns true if the SortedList has a fixed size and cannot dynamically grow or shrink, or false if it can be modified. A regular SortedList object is not fixed in size by default, which means you can add or remove elements dynamically. However, you can create a fixed-size wrapper using methods like SortedList.Synchronized() combined with other collection wrappers. Syntax Following is the syntax for checking if a SortedList has a fixed size − bool isFixed ...

Read More

Get a collection of values in the StringDictionary in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 188 Views

The StringDictionary class in C# provides a collection that maps strings to strings, where keys are case-insensitive. To retrieve values from a StringDictionary, you can access the Values property or iterate through key-value pairs to extract the values. StringDictionary automatically converts all keys to lowercase, making it useful for scenarios where case-insensitive string lookups are required. Syntax Following is the syntax to access values in a StringDictionary − StringDictionary stringDict = new StringDictionary(); ICollection values = stringDict.Values; string value = stringDict[key]; Using Values Property The Values property returns an ICollection containing all ...

Read More

Check if two ArrayList objects are equal in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 413 Views

Checking if two ArrayList objects are equal in C# involves understanding how the Equals() method works. The ArrayList.Equals() method checks for reference equality, not content equality. This means it only returns true if both variables point to the same object in memory. Understanding ArrayList.Equals() Behavior The Equals()

Read More

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

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 158 Views

The SortedSet class in C# provides the IsSubsetOf() method to check if all elements of one SortedSet are contained within another collection. A subset means that every element in the first set exists in the second set, though the second set may contain additional elements. Syntax Following is the syntax for the IsSubsetOf() method − public bool IsSubsetOf(IEnumerable other) Parameters other − The collection to compare with the current SortedSet. Return Value Returns true if the current SortedSet is a subset of the specified collection; otherwise, false. ...

Read More
Showing 251–260 of 1,951 articles
« Prev 1 24 25 26 27 28 196 Next »
Advertisements