karthikeya Boyini

karthikeya Boyini

1,421 Articles Published

Articles by karthikeya Boyini

Page 21 of 143

C# Console.WindowWidth Property

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

The Console.WindowWidth property gets or sets the width of the console window measured in columns. This property is useful for creating console applications that need to adapt their output formatting based on the current window dimensions. Syntax Following is the syntax to get the console window width − int width = Console.WindowWidth; Following is the syntax to set the console window width − Console.WindowWidth = value; Return Value The property returns an int representing the width of the console window in columns. When setting the property, the value must ...

Read More

C# program to find the maximum of three numbers

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

Finding the maximum of three numbers is a fundamental programming problem that demonstrates conditional logic and comparison operations. This can be achieved using nested if-else statements to compare the numbers systematically. Logic The algorithm compares numbers in pairs − First, compare num1 with num2 If num1 is greater, compare num1 with num3 If num2 is greater than num1, compare num2 with num3 The winner of each comparison is the maximum Finding Maximum Logic Flow num1 num2 ...

Read More

C# Linq Last() Method

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

The LINQ Last() method in C# returns the last element from a sequence. It throws an exception if the sequence is empty, making it suitable when you are certain the collection contains elements. Syntax Following is the syntax for the Last() method − public static TSource Last(this IEnumerable source); public static TSource Last(this IEnumerable source, Func predicate); Parameters source − The sequence to return the last element from. predicate − (Optional) A function to test each element for a condition. Return Value Returns the last ...

Read More

C# Program to Create a Thread Pool

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

A thread pool in C# is a collection of pre-created threads that can be reused to execute multiple tasks efficiently. Instead of creating new threads for each task, the thread pool manages a pool of worker threads, reducing the overhead of thread creation and destruction. The ThreadPool class provides methods to queue work items for execution by available threads in the pool. This approach is particularly useful for short-running tasks that don't require dedicated threads. Syntax Following is the syntax for queueing a method for execution in the thread pool − ThreadPool.QueueUserWorkItem(new WaitCallback(methodName)); ...

Read More

What is a sealed class in C#?

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

A sealed class in C# is a class that cannot be inherited by other classes. When you declare a class as sealed, it prevents any other class from deriving from it. The sealed keyword can also be applied to methods to prevent them from being overridden in further derived classes. Sealed classes are useful when you want to restrict inheritance for security, performance, or design reasons. Common examples include the string class and many value types in .NET Framework. Syntax Following is the syntax for declaring a sealed class − public sealed class ClassName { ...

Read More

Convert.ToUInt32 Method in C#

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

The Convert.ToUInt32 method in C# converts a specified value to a 32-bit unsigned integer (uint). This method can convert various data types including strings, integers, floating-point numbers, and other numeric types to an unsigned 32-bit integer. The uint data type can hold values from 0 to 4, 294, 967, 295, making it suitable for scenarios where you need positive integers only with a larger range than regular int. Syntax Following are the common overloads of the Convert.ToUInt32 method − Convert.ToUInt32(string value) Convert.ToUInt32(int value) Convert.ToUInt32(double value) Convert.ToUInt32(object value) Parameters value − The ...

Read More

C# program to find the sum of digits of a number using Recursion

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

A recursive function calls itself with modified parameters until it reaches a base case. To find the sum of digits of a number using recursion, we extract the last digit using the modulus operator (%) and add it to the sum of remaining digits. Syntax Following is the syntax for a recursive function to sum digits − public int SumOfDigits(int number) { if (number == 0) { return 0; // base case } return (number % 10) + SumOfDigits(number / ...

Read More

What does Array.LongLength property of array class do in C#?

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

The Array.LongLength property in C# gets a 64-bit integer (long) that represents the total number of elements in all dimensions of an array. This property is particularly useful when working with very large arrays that might exceed the range of a 32-bit integer. Syntax Following is the syntax for using the LongLength property − long totalElements = arrayName.LongLength; Return Value The property returns a long value representing the total number of elements across all dimensions of the array. Single-Dimensional Array Example For a single-dimensional array, LongLength returns the same value as ...

Read More

Compare two strings lexicographically in C#

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

The String.Compare() method in C# performs lexicographic (alphabetical) comparison between two strings. It compares strings character by character based on their Unicode values and is case-sensitive by default. Syntax Following is the syntax for the basic String.Compare() method − int result = string.Compare(string1, string2); For case-insensitive comparison − int result = string.Compare(string1, string2, true); Return Value The String.Compare() method returns an integer value indicating the lexicographic relationship between the two strings − If str1 is less than str2, it returns -1. If str1 is equal to str2, ...

Read More

Understanding IndexOutOfRangeException Exception in C#

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

The IndexOutOfRangeException is a common runtime exception in C# that occurs when you attempt to access an array element using an index that is outside the valid range of indices for that array. This exception helps prevent memory corruption by catching invalid array access attempts. Arrays in C# are zero-indexed, meaning the first element is at index 0, and the last element is at index length - 1. Attempting to access an index less than 0 or greater than or equal to the array length will throw this exception. When IndexOutOfRangeException Occurs This exception is thrown in ...

Read More
Showing 201–210 of 1,421 articles
« Prev 1 19 20 21 22 23 143 Next »
Advertisements