Articles on Trending Technologies

Technical articles with clear explanations and examples

Decimal.Add() Method in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 1K+ Views

The Decimal.Add() method in C# is a static method that adds two specified decimal values and returns their sum. This method provides precise decimal arithmetic, which is essential for financial calculations where floating-point errors must be avoided. Syntax Following is the syntax − public static decimal Add(decimal val1, decimal val2); Parameters val1 − The first decimal value to add. val2 − The second decimal value to add. Return Value Returns a decimal value that represents the sum of val1 and val2. Using Decimal.Add() with Regular Values Example ...

Read More

What is composition in C#?

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

Composition in C# is a design principle where one class contains an instance of another class as a private member, creating a "has-a" relationship. In composition, the contained object (child) cannot exist independently of the container object (parent). When the parent object is destroyed, the child object is also destroyed, establishing a strong ownership relationship. Composition represents a part-of relationship, which is a special type of association that implies strong coupling between objects. Syntax Following is the basic syntax for implementing composition in C# − public class ContainedClass { // properties and ...

Read More

Implicit conversion from 64-bit signed integer (long) to Decimal in C#

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

The long type represents a 64-bit signed integer in C#. C# allows implicit conversion from long to decimal because no data loss occurs during this conversion. The decimal type can accommodate all possible long values while providing higher precision. Syntax Following is the syntax for implicit conversion from long to decimal − long longValue = 123456789; decimal decimalValue = longValue; // Implicit conversion How It Works The conversion happens automatically because the decimal type has a wider range and higher precision than long. The decimal type can represent all integer values that ...

Read More

Decimal.Ceiling() Method in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 452 Views

The Decimal.Ceiling() method in C# returns the smallest integral value that is greater than or equal to the specified decimal number. This method rounds up to the nearest whole number, regardless of whether the decimal portion is less than or greater than 0.5. Syntax Following is the syntax − public static decimal Ceiling(decimal val); Parameters val − A decimal number that needs to be rounded up to the nearest integer. Return Value Returns a decimal value representing the smallest integer greater than or equal to the input value. ...

Read More

What is C# Programming?

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

C# is a modern, general-purpose, object-oriented programming language developed by Microsoft in 2000. It was created by Anders Hejlsberg and his team as part of Microsoft's .NET initiative to provide a robust, type-safe language that combines the power of C++ with the simplicity of Visual Basic. C# is designed for the Common Language Infrastructure (CLI), which consists of executable code and a runtime environment that allows various high-level languages to run on different computer platforms and architectures. The language compiles to bytecode called Common Intermediate Language (CIL), which runs on the .NET runtime. Key Features of C# ...

Read More

C# Exponential ("E") Format Specifier

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

The Exponential ("E") format specifier in C# converts a number to scientific notation. It represents numbers in the form of a coefficient multiplied by a power of 10, making it ideal for very large or very small numbers. Syntax The exponential format specifier has the following syntax − "E" or "e" "En" or "en" (where n specifies decimal places) The resulting string format is − "-d.ddd...E+ddd" or "-d.ddd...e+ddd" Where "d" represents a digit (0-9). The "E" or "e" separates the coefficient from the exponent. Exponential ...

Read More

Compute modulus division by a power-of-2-number in C#

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

Computing modulus division by a power-of-2 number in C# can be optimized using bitwise operations. When the divisor is a power of 2 (like 2, 4, 8, 16, etc.), we can use the bitwise AND operation with (divisor - 1) instead of the traditional modulus operator for better performance. This optimization works because powers of 2 in binary have only one bit set, and subtracting 1 creates a mask that isolates the relevant lower bits. Syntax Following is the syntax for computing modulus with a power-of-2 divisor − result = dividend & (divisor - 1); ...

Read More

What is a parameterized constructor in C# programs?

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

A parameterized constructor in C# is a constructor that accepts parameters to initialize an object with specific values at the time of creation. This allows you to set initial values for the object's fields or properties during instantiation, making object creation more flexible and efficient. Syntax Following is the syntax for declaring a parameterized constructor − public ClassName(dataType parameter1, dataType parameter2) { // initialization code this.field1 = parameter1; this.field2 = parameter2; } To create an object using a parameterized constructor − ClassName objectName ...

Read More

What is Cast Operator () in C#?

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

The cast operator () in C# is used for explicit type conversion, converting one data type to another when an implicit conversion is not available or when you want to force a specific conversion. It requires you to explicitly specify the target type in parentheses before the value or variable. Syntax Following is the syntax for using the cast operator − (target_type) expression Where target_type is the type you want to convert to, and expression is the value or variable being converted − int result = (int) doubleValue; float floatResult = (float) ...

Read More

How to find the length of jagged array using a property?

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

A jagged array in C# is an array of arrays where each inner array can have different lengths. To find the length of a jagged array, you use the Length property, which returns the number of inner arrays (rows) in the jagged array. Syntax Following is the syntax for declaring a jagged array − dataType[][] arrayName = new dataType[size][]; To get the length of a jagged array, use the Length property − int numberOfRows = arrayName.Length; Jagged Array Structure [0, 0] ...

Read More
Showing 10401–10410 of 61,297 articles
Advertisements