Articles on Trending Technologies

Technical articles with clear explanations and examples

Compound assignment operators in C#

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

Compound assignment operators in C# provide a shorter syntax to perform an operation and assign the result back to the same variable. These operators combine arithmetic, bitwise, or shift operations with assignment in a single step. For example, x += 5 is equivalent to x = x + 5, but more concise and readable. Syntax The general syntax for compound assignment operators is − variable operator= value; This is equivalent to − variable = variable operator value; Types of Compound Assignment Operators Operator Name Equivalent ...

Read More

C# program to print all sublists of a list

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

A sublist (or subsequence) of a string contains characters from the original string in the same order, but not necessarily consecutive. For example, from the string "xyz", possible sublists include "x", "xy", "xz", "y", "yz", "z", and "xyz". This program generates all possible sublists of a given string by building them incrementally using nested loops and dynamic list operations. How the Algorithm Works The algorithm processes each character of the input string and creates new sublists by combining existing sublists with the current character. It maintains a list that grows with each iteration, containing all possible sublists ...

Read More

Large Fibonacci Numbers in C#

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

To display large Fibonacci numbers in C#, we need to handle numbers that exceed the range of standard integer types. The Fibonacci sequence grows exponentially, so after just 40-50 terms, the values become too large for int or even long data types. For truly large Fibonacci numbers, we use the BigInteger class from System.Numerics, which can handle arbitrarily large integers without overflow. Syntax Following is the basic syntax for generating Fibonacci numbers − int val1 = 0, val2 = 1, val3; for (int i = 2; i < n; i++) { val3 ...

Read More

How to print the contents of array horizontally using C#?

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

Printing array contents horizontally in C# means displaying all elements in a single line, separated by spaces or other delimiters. This is useful for creating formatted output where elements appear side by side rather than vertically. When you print an array using a regular loop with Console.WriteLine(), each element appears on a new line. To display elements horizontally, C# provides several approaches. Syntax Using string.Join() method − string.Join(separator, array) Using Console.Write() in a loop − for (int i = 0; i < array.Length; i++) { Console.Write(array[i] + ...

Read More

Constructor Overloading in C#

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

Constructor overloading in C# allows you to define multiple constructors within the same class, each with different parameters. This provides flexibility in object initialization, allowing different ways to create instances of the same class. Constructor overloading follows the same rules as method overloading − constructors must have different parameter lists (number, type, or order of parameters). Syntax Following is the syntax for constructor overloading − public class ClassName { public ClassName() { // default constructor } ...

Read More

How to check if a C# list is empty?

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

In C#, there are several ways to check if a List is empty. The most common approaches include using the Count property, the Any() LINQ method, or comparing against an empty collection. Syntax Following are the common syntaxes for checking if a list is empty − // Using Count property if (list.Count == 0) { } // Using Any() method if (!list.Any()) { } // Using Count with comparison if (list.Count > 0) { } Using Count Property The Count property returns the number of elements in the list. When Count ...

Read More

How to access elements from an array in C#?

Ankith Reddy
Ankith Reddy
Updated on 17-Mar-2026 966 Views

Arrays in C# are collections of elements that can be accessed using an index. Array indexing starts from 0, meaning the first element is at index 0, the second at index 1, and so on. Syntax Following is the syntax for accessing array elements by index − arrayName[index] Following is the syntax for declaring and initializing an array − dataType[] arrayName = new dataType[size] {element1, element2, element3}; Using Index to Access Elements Each element in an array has a specific position called an index. You can access any element ...

Read More

Global and Local Variables in C#

Giri Raju
Giri Raju
Updated on 17-Mar-2026 5K+ Views

In C#, variables are classified by their scope − the region of code where they can be accessed. The two main types are local variables (declared within methods) and global variables (which C# handles through static class members and namespace aliases). Local Variables A local variable is declared within a method, constructor, or block of code. Its scope is limited to that specific block, meaning it can only be accessed within the method or block where it was declared. Syntax dataType variableName; // or dataType variableName = value; Example using System; ...

Read More

Path methods in C#

Samual Sam
Samual Sam
Updated on 17-Mar-2026 339 Views

To handle File Paths in C#, use the Path methods. These methods come under the System.IO namespace and provide a reliable way to work with file and directory paths across different operating systems. The Path class contains static methods that perform common operations on strings that contain file or directory path information. These methods handle path separators, invalid characters, and other platform-specific details automatically. Syntax Following is the syntax for commonly used Path methods − string extension = Path.GetExtension(path); string fileName = Path.GetFileName(path); string fileNameWithoutExt = Path.GetFileNameWithoutExtension(path); string directoryName = Path.GetDirectoryName(path); string fullPath = Path.GetFullPath(path); ...

Read More

Constructors in C#

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

A constructor in C# is a special method that gets invoked automatically when an object is created. The constructor has the same name as the class and is used to initialize the object's state. Constructors do not have a return type, not even void. Syntax Following is the basic syntax for declaring a constructor − public class ClassName { public ClassName() { // constructor body } } Types of Constructors C# supports several types of constructors − Default ...

Read More
Showing 11301–11310 of 61,297 articles
Advertisements