Csharp Articles

Page 77 of 196

Static binding vs Dynamic binding in C#

Arjun Thakur
Arjun Thakur
Updated on 17-Mar-2026 3K+ Views

Polymorphism can be static or dynamic. In static polymorphism, the method to be called is determined at compile time. In dynamic polymorphism, the decision is made at runtime based on the actual object type. Static Binding (Compile-Time Polymorphism) Static binding links a function with an object during compile time. It is also called early binding. This is achieved through method overloading and operator overloading. Static Binding Process Source Code Method calls Compiler Resolves calls ...

Read More

How to delete/remove an element from a C# array?

Chandu yadav
Chandu yadav
Updated on 17-Mar-2026 11K+ Views

In C#, arrays have a fixed size once created, so you cannot truly delete an element. However, you can remove an element by shifting the remaining elements to fill the gap, or use collections like List for dynamic removal. Understanding Array Element Removal When removing an element from an array, the process involves shifting all elements after the target position one position to the left, effectively overwriting the element to be removed. Array Element Removal Process Original: 35 ...

Read More

Try-Catch-Finally in C#

Samual Sam
Samual Sam
Updated on 17-Mar-2026 7K+ Views

The try-catch-finally statement in C# provides a structured way to handle exceptions that may occur during program execution. It allows you to gracefully handle errors like division by zero, file access failures, or network timeouts without crashing your application. Exception handling in C# is performed using three main keywords that work together to create a robust error handling mechanism. Syntax Following is the basic syntax of try-catch-finally statement − try { // Code that may throw an exception } catch (ExceptionType ex) { // Handle the exception } finally ...

Read More

Transpose a matrix in C#

George John
George John
Updated on 17-Mar-2026 3K+ Views

Transpose of a matrix flips the matrix over its diagonal, swapping rows and columns. This operation converts the element at position [i][j] to position [j][i] in the transposed matrix. For example − Matrix before Transpose: 1 2 3 4 5 6 7 8 9 Matrix after Transpose: 1 4 7 2 5 8 3 6 9 Matrix Transpose Operation Original Matrix 1 2 3 4 5 6 7 8 9 rows columns ...

Read More

Value Type vs Reference Type in C#

Ankith Reddy
Ankith Reddy
Updated on 17-Mar-2026 8K+ Views

Value type and reference type are two fundamental categories of data types in C#. Understanding their differences is crucial for memory management and program behavior. Value types store data directly, while reference types store a reference to the memory location where the data is stored. Syntax Following is the syntax for declaring value type variables − int number = 10; char letter = 'A'; bool flag = true; Following is the syntax for declaring reference type variables − string text = "Hello"; object obj = new object(); int[] array = new int[5]; ...

Read More

How to add items/elements to an existing jagged array in C#?

Ankith Reddy
Ankith Reddy
Updated on 17-Mar-2026 1K+ Views

Adding items to an existing jagged array in C# can be accomplished through several methods. You can modify individual elements directly, replace entire sub-arrays, or dynamically resize arrays using collections. The approach depends on whether you want to change existing elements or expand the array structure. Understanding Jagged Arrays A jagged array is an array of arrays where each sub-array can have different lengths. Unlike multidimensional arrays, jagged arrays provide flexibility in storing data with varying row sizes. Jagged Array Structure arr[0] arr[1] ...

Read More

What is index-based I/O BitArray collection in C#?

Chandu yadav
Chandu yadav
Updated on 17-Mar-2026 242 Views

The BitArray class in C# manages a compact array of bit values represented as Boolean values, where true indicates the bit is on (1) and false indicates the bit is off (0). It is part of the System.Collections namespace and provides an efficient way to store and manipulate bits. BitArray is particularly useful for scenarios requiring bitwise operations, boolean flags, or when memory efficiency is crucial since it stores bits compactly rather than using full bytes for each boolean value. Syntax Following is the syntax for creating a BitArray − BitArray bitArray = new BitArray(size); ...

Read More

What are the differences between a multi-dimensional array and jagged array?

Samual Sam
Samual Sam
Updated on 17-Mar-2026 1K+ Views

Multi-dimensional arrays and jagged arrays are two different ways to work with nested data structures in C#. Understanding their differences is crucial for choosing the right approach for your specific use case. Multi-dimensional Arrays A multi-dimensional array is also called a rectangular array because all rows have the same number of columns, forming a rectangular structure. All sub-arrays must have identical lengths. Syntax Following is the syntax for declaring multi-dimensional arrays − // 2D array int[, ] array2D = new int[rows, columns]; // 3D array int[, , ] array3D = new ...

Read More

C# Numeric Promotion

Arjun Thakur
Arjun Thakur
Updated on 17-Mar-2026 449 Views

Numeric promotion in C# is the automatic conversion of smaller numeric types to larger types during arithmetic operations. This ensures that operations between different numeric types can be performed without data loss, following C#'s type promotion rules. When performing arithmetic operations, C# automatically promotes operands to a common type that can safely hold the result. For example, when multiplying a short and ushort, both are promoted to int before the operation. How Numeric Promotion Works The C# compiler follows a specific hierarchy when promoting numeric types during arithmetic operations − Numeric Promotion ...

Read More

Decimal to Multiple-Bases Conversion with Stack

karthikeya Boyini
karthikeya Boyini
Updated on 17-Mar-2026 738 Views

Decimal to multiple-base conversion is a common programming task where we convert a decimal number to binary, octal, hexadecimal, or any other base. Using a stack data structure makes this process efficient because stacks follow the Last-In-First-Out (LIFO) principle, which naturally reverses the remainder sequence obtained during division. How It Works The conversion algorithm repeatedly divides the decimal number by the target base and stores remainders in a stack. When we pop elements from the stack, we get the digits in the correct order for the converted number. Decimal to Binary Conversion (45 ...

Read More
Showing 761–770 of 1,951 articles
« Prev 1 75 76 77 78 79 196 Next »
Advertisements