Articles on Trending Technologies

Technical articles with clear explanations and examples

What is aggregation in C#?

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

Aggregation in C# represents a has-a relationship between objects where one class contains or uses another class. In aggregation, the contained object can exist independently of the container object, making it a weak association. For example, an Employee has an Address, and a Department has multiple Employees. The key characteristic of aggregation is that when the container object is destroyed, the contained objects continue to exist independently. Syntax Following is the syntax for implementing aggregation in C# − public class ContainerClass { private ContainedClass containedObject; ...

Read More

Mathematical Functions in C#

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

The System.Math class in C# provides methods and properties to perform mathematical operations, trigonometric calculations, logarithmic functions, and other common mathematical computations. All methods in the Math class are static, meaning you can call them directly without creating an instance. Common Mathematical Methods The following table shows some of the most commonly used methods in the Math class − Method Description Abs() Returns the absolute value of a number (works with decimal, double, int, etc.) Ceiling() Returns the smallest integer greater than or equal to the specified number ...

Read More

How to List all Substrings in a given String using C#?

George John
George John
Updated on 17-Mar-2026 725 Views

A substring is any contiguous sequence of characters within a string. In C#, you can generate all possible substrings of a given string using the Substring() method with nested loops to iterate through different starting positions and lengths. Syntax The Substring() method extracts a portion of a string − string.Substring(startIndex, length) To generate all substrings, use nested loops − for (int length = 1; length

Read More

C# Console.WindowWidth Property

karthikeya Boyini
karthikeya Boyini
Updated on 17-Mar-2026 505 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 perform all Basic Arithmetic Operations

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

Basic arithmetic operators in C# allow you to perform mathematical calculations such as addition, subtraction, multiplication, division, and modulus operations. These operators work with numeric data types and form the foundation of mathematical computations in C#. Arithmetic Operators Operator Description + Adds two operands - Subtracts the second operand from the first * Multiplies both operands / Divides the numerator by denominator % Modulus operator returns the remainder after division ++ Increment operator increases integer value by one -- ...

Read More

What is a copy constructor in C#?

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

A copy constructor in C# creates a new object by copying variables from another object of the same class. It provides a way to initialize a new object with the values of an existing object, creating a separate copy rather than a reference to the original object. Syntax Following is the syntax for creating a copy constructor − public ClassName(ClassName obj) { this.field1 = obj.field1; this.field2 = obj.field2; // copy other fields } How Copy Constructor Works A copy constructor takes an object of ...

Read More

Convert.ChangeType Method in C#

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

The Convert.ChangeType() method in C# converts a value to a specified type. It returns an object of the target type whose value is equivalent to the original object. This method is particularly useful when you need to perform type conversions at runtime or when working with generic code. Syntax Following is the syntax for the Convert.ChangeType() method − public static object ChangeType(object value, Type conversionType) public static object ChangeType(object value, TypeCode typeCode) Parameters value − The object to convert. conversionType − The target Type to convert to. typeCode − The TypeCode representing ...

Read More

Convert.ToBoolean Method in C#

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

The Convert.ToBoolean method in C# converts a specified value to an equivalent Boolean value. This method follows specific rules depending on the input type − numeric types return false if zero, true otherwise; string values are parsed based on their content. Syntax Following is the syntax for the Convert.ToBoolean method − public static bool ToBoolean(object value); public static bool ToBoolean(string value); public static bool ToBoolean(int value); public static bool ToBoolean(double value); // Other overloads for different data types Parameters value − The value to convert to a Boolean. Can be a ...

Read More

Convert.ToByte Method in C#

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

The Convert.ToByte method in C# converts a specified value to an 8-bit unsigned integer (byte). A byte can hold values from 0 to 255, making it useful for representing small integers, ASCII characters, and binary data. This method provides a safe way to convert various data types to byte values, with built-in overflow checking that throws an OverflowException if the value is outside the valid byte range. Syntax Following are the common overloads of the Convert.ToByte method − Convert.ToByte(object value) Convert.ToByte(string value) Convert.ToByte(char value) Convert.ToByte(int value) Convert.ToByte(double value) Parameters value − ...

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
Showing 11211–11220 of 61,297 articles
Advertisements