karthikeya Boyini

karthikeya Boyini

1,421 Articles Published

Articles by karthikeya Boyini

Page 17 of 143

C# Queryable Union Method

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

The Queryable Union method in C# performs a set union operation on two sequences, returning all unique elements from both sequences. It removes duplicate elements and preserves the order of first occurrence. Syntax Following is the syntax for the Queryable Union method − public static IQueryable Union( this IQueryable source1, IEnumerable source2 ) Parameters source1 − An IQueryable whose distinct elements form the first set for the union. source2 − An IEnumerable whose distinct elements form the second set for the union. ...

Read More

How to generate the first 100 even Numbers using C#?

karthikeya Boyini
karthikeya Boyini
Updated on 17-Mar-2026 3K+ Views

To generate the first 100 even numbers in C#, you can use a for loop and check if each number is divisible by 2. An even number has no remainder when divided by 2, which can be tested using the modulo operator (%). What are Even Numbers? Even numbers are integers that are divisible by 2 without a remainder. Examples include 2, 4, 6, 8, 10, and so on. The condition number % 2 == 0 identifies even numbers. Even Number Test Number 8 ...

Read More

What is the octal equivalent of a decimal number in C#?

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

To get the octal equivalent of a decimal number in C#, you need to repeatedly divide the decimal number by 8 and store the remainders. The octal number system uses base 8 (digits 0-7), while decimal uses base 10. Syntax Following is the basic algorithm for decimal to octal conversion − while (decimal != 0) { remainder = decimal % 8; decimal = decimal / 8; // store remainder in array } How It Works The conversion process involves dividing the decimal number by ...

Read More

Get the width and height of a three-dimensional array

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

To get the width and height of a three-dimensional array in C#, we use the Array.GetLength() method. This method returns the number of elements in a specified dimension of the array. In a three-dimensional array declared as int[, , ] arr = new int[3, 4, 5], the dimensions represent different aspects of the array structure. Syntax Following is the syntax for getting dimensions of a three-dimensional array − arrayName.GetLength(dimension) Where dimension is − 0 − First dimension (rows) 1 − Second dimension (columns) 2 − Third dimension (depth) Understanding ...

Read More

How do I sort a two-dimensional array in C#

karthikeya Boyini
karthikeya Boyini
Updated on 17-Mar-2026 2K+ Views

Sorting a two-dimensional array in C# can be accomplished using several approaches. The most common methods include sorting individual rows using nested loops with bubble sort, using Array.Sort() for jagged arrays, or converting to a one-dimensional array for sorting. Syntax For sorting rows in a 2D array using nested loops − for (int i = 0; i < arr.GetLength(0); i++) { for (int j = 0; j < arr.GetLength(1) - 1; j++) { for (int k = 0; k < arr.GetLength(1) - j - 1; k++) { ...

Read More

What is the difference between declaration and definition in C#?

karthikeya Boyini
karthikeya Boyini
Updated on 17-Mar-2026 12K+ Views

In C#, declaration means specifying the type and name of a variable, method, or class without providing an initial value or implementation. Definition (or initialization) means providing an actual value or implementation to what was declared. This distinction applies to variables, arrays, methods, and classes. Understanding the difference helps write cleaner code and avoid compilation errors. Syntax Following is the syntax for declaration − datatype variableName; Following is the syntax for definition/initialization − variableName = value; // or combined declaration and initialization datatype variableName = value; Variable Declaration vs ...

Read More

What are the escape sequences supported by C#?

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

Escape sequences in C# are special character combinations that start with a backslash (\) and represent characters that are difficult or impossible to type directly. These sequences allow you to include special characters like newlines, tabs, quotes, and control characters in your strings. Syntax Following is the syntax for escape sequences in C# − string text = "HelloWorld"; // represents a newline char tab = '\t'; // \t represents a tab character Common Escape Sequences ...

Read More

C# Program to convert a Double value to an Int64 value

karthikeya Boyini
karthikeya Boyini
Updated on 17-Mar-2026 2K+ Views

To convert a Double value to an Int64 value, use the Convert.ToInt64() method. This method performs a rounded conversion from a 64-bit floating-point number to a 64-bit signed integer. Int64 represents a 64-bit signed integer and is equivalent to the long data type in C#. The conversion truncates the decimal portion and rounds to the nearest integer value. Syntax Following is the syntax for converting a double to Int64 − long result = Convert.ToInt64(doubleValue); Parameters doubleValue − A double-precision floating-point number to be converted. Return Value Returns a ...

Read More

How do you use 'foreach' statement for accessing array elements in C#

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

The foreach statement in C# provides a simple way to iterate through all elements in an array without needing to manage index variables. Unlike a traditional for loop, foreach automatically accesses each element in sequence. Syntax Following is the syntax for using foreach with arrays − foreach (dataType variable in arrayName) { // code to process each element } The foreach loop automatically iterates through each element, assigning the current element's value to the specified variable. Using foreach with Arrays Example using System; class MyArray { ...

Read More

What are dynamic arrays in C#?

karthikeya Boyini
karthikeya Boyini
Updated on 17-Mar-2026 7K+ Views

Dynamic arrays are growable arrays that can resize themselves during runtime, providing a significant advantage over static arrays which have a fixed size. In C#, you can create dynamic arrays using collections like ArrayList and the more modern List. These dynamic collections allow automatic memory allocation, resizing, adding, searching, and sorting items efficiently. The ArrayList stores objects of any type, while List is type-safe and performs better. Syntax Following is the syntax for creating an ArrayList − ArrayList arrayList = new ArrayList(); arrayList.Add(item); Following is the syntax for creating a generic List − ...

Read More
Showing 161–170 of 1,421 articles
« Prev 1 15 16 17 18 19 143 Next »
Advertisements