Articles on Trending Technologies

Technical articles with clear explanations and examples

Adding an element to the List in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 424 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

How to explicitly call base class constructor from child class in C#?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 17-Mar-2026 2K+ Views

The base keyword in C# is used to explicitly call a constructor from the parent class when creating an instance of a derived class. This is essential when the base class doesn't have a parameterless constructor or when you need to pass specific values to initialize the base class properly. By default, C# automatically calls the parameterless constructor of the base class. However, when the base class only has parameterized constructors, you must explicitly specify which constructor to call using the base keyword. Syntax Following is the syntax for calling a base class constructor from a derived ...

Read More

How to get the name of the current executable in C#?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 17-Mar-2026 5K+ Views

There are several ways to get the name of the current executable in C#. Each method provides different levels of detail about the executable file, from just the name to the full path. Using System.AppDomain The AppDomain.CurrentDomain.FriendlyName property provides the name of the current application domain, which typically corresponds to the executable filename including its extension. Example using System; namespace DemoApplication { public class Program { public static void Main() { ...

Read More

Byte Struct in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 394 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

Which one is better Build, Rebuild, or Clean in C#?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 17-Mar-2026 406 Views

When working with C# projects in Visual Studio, you have three main build options: Build, Rebuild, and Clean. Each serves a different purpose and understanding when to use each one can significantly improve your development workflow and troubleshoot compilation issues. Build Solution The Build option performs an incremental build, which means it only compiles code files that have changed since the last build. This is the most efficient option for regular development work. Key characteristics of Build − Only compiles modified files and their dependencies Fastest build option for development Preserves existing compiled files that ...

Read More

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

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 594 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 432 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 201 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

How to Get Hashtable Elements as Sorted Array?

Shilpa Nadkarni
Shilpa Nadkarni
Updated on 17-Mar-2026 3K+ Views

A Hashtable is a non-generic collection of key-value pairs that are arranged according to the hash code of the key. The hashtable optimizes lookups by calculating the hash code of each key and storing it internally. When accessing a particular value, this hash code is matched with the specified key. This hashtable collection is defined in the System.Collections namespace of C#. The class that represents the hashtable collection is the Hashtable class. By default, hashtable collections are unsorted. To get sorted data, we need to extract the elements into an Array and sort them. Why Hashtables Are Unsorted ...

Read More

What are union, intersect and except operators in Linq C#?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 17-Mar-2026 823 Views

LINQ set operators in C# allow you to perform set-based operations on collections. The three primary set operators are Union, Intersect, and Except, which enable you to combine, find common elements, and identify differences between sequences. These operators work with any IEnumerable collections and return distinct results by default, making them useful for data manipulation and filtering operations. Syntax Following is the syntax for the three LINQ set operators − // Union - combines two sequences and removes duplicates var result = sequence1.Union(sequence2); // Intersect - returns common elements from both sequences var result ...

Read More
Showing 10021–10030 of 61,299 articles
Advertisements