AmitDiwan

AmitDiwan

8,392 Articles Published

Articles by AmitDiwan

Page 197 of 840

Get the HashCode for the current UInt64 instance in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 207 Views

The GetHashCode() method in C# returns a hash code for the current UInt64 instance. Hash codes are primarily used in hash tables and dictionaries to quickly locate objects. For UInt64 values, the hash code is typically derived from the numeric value itself. Syntax Following is the syntax for getting the hash code of a UInt64 instance − public override int GetHashCode() Return Value The method returns a 32-bit signed integer hash code representing the current UInt64 value. Using GetHashCode() with Small Values For smaller UInt64 values that fit within the range ...

Read More

Queue.GetEnumerator() Method in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 183 Views

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 More

Adding an element to the List in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 321 Views

The List class in C# provides the Add() method to add elements to the end of the list. This method is part of the System.Collections.Generic namespace and allows you to dynamically grow the list by appending new elements. Syntax Following is the syntax for adding an element to a List − list.Add(element); Parameters element − The object to be added to the end of the List. The value can be null for reference types. Adding String Elements to List using System; using System.Collections.Generic; public class Demo { ...

Read More

Byte Struct in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 342 Views

The byte struct in C# represents an 8-bit unsigned integer that can store values from 0 to 255. It is one of the fundamental value types in .NET and provides various methods for comparison, conversion, and formatting operations. Syntax Following is the syntax for declaring and initializing a byte variable − byte variableName = value; // value must be between 0 and 255 Fields The byte struct provides two important constant fields − Field Description Value MaxValue Represents the largest possible value of a ...

Read More

How to change the visibility of the Cursor of Console in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 492 Views

The Console.CursorVisible property in C# allows you to control whether the cursor is visible in the console window. This property accepts a boolean value where true makes the cursor visible and false hides it. Syntax Following is the syntax for using the Console.CursorVisible property − Console.CursorVisible = true; // Makes cursor visible Console.CursorVisible = false; // Hides cursor To check the current visibility status − bool isVisible = Console.CursorVisible; Example - Hiding the Cursor Let us see an example that demonstrates hiding the cursor − using ...

Read More

Random.NextBytes() Method in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 401 Views

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 More

Set all bits in the BitArray to the specified value in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 151 Views

The BitArray.SetAll() method in C# is used to set all bits in the BitArray to a specified boolean value. This method provides an efficient way to initialize or reset all elements in a BitArray with a single operation, rather than setting each bit individually. Syntax Following is the syntax for the SetAll() method − public void SetAll(bool value) Parameters value: A boolean value (true or false) to assign to all bits in the BitArray. Using SetAll() to Set All Bits to True The following example demonstrates setting all bits in a ...

Read More

Int64.ToString() Method in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 562 Views

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 More

Adding new node or value at the end of LinkedList in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 206 Views

The LinkedList class in C# provides the AddLast() method to add new nodes or values at the end of the linked list. This method maintains the sequential order and automatically updates the internal node structure. Syntax Following is the syntax for adding elements at the end of a LinkedList − LinkedList list = new LinkedList(); list.AddLast(value); The AddLast() method has two overloads − public LinkedListNode AddLast(T value) public void AddLast(LinkedListNode node) Parameters value − The value to add at the end of the LinkedList. node − The LinkedListNode ...

Read More

How to change the WindowLeft of the Console

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 185 Views

The Console.WindowLeft property in C# gets or sets the leftmost position of the console window area relative to the screen buffer. This property controls the horizontal scrolling position of the console window within the buffer. Syntax Following is the syntax for using the Console.WindowLeft property − Console.WindowLeft = value; int leftPosition = Console.WindowLeft; Parameters The WindowLeft property accepts an int value representing the column position (0-based) where the left edge of the console window should be positioned within the screen buffer. Key Rules The value must be greater than ...

Read More
Showing 1961–1970 of 8,392 articles
« Prev 1 195 196 197 198 199 840 Next »
Advertisements