Programming Articles

Page 774 of 2547

Decimal.Ceiling() Method in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 451 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 356 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 201 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 870 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

C# Fixed-Point ("F") Format Specifier

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

The Fixed-Point ("F") format specifier in C# converts a number to a string with a fixed number of decimal places. It produces output in the form "-ddd.ddd..." where "d" represents a digit (0-9). The negative sign appears only for negative numbers. Syntax Following is the syntax for using the Fixed-Point format specifier − number.ToString("F") // Default 2 decimal places number.ToString("Fn") // n decimal places (0-99) number.ToString("F", culture) // With specific culture Default Precision When no precision ...

Read More

Compressing and Decompressing files in C#

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

File compression and decompression in C# is accomplished using the System.IO.Compression namespace. This namespace provides classes like GZipStream and ZipArchive for handling compressed files efficiently. Syntax Following is the syntax for compressing files using GZipStream − using (var compressStream = new GZipStream(outputStream, CompressionMode.Compress)) { // write data to compress } Following is the syntax for decompressing files using GZipStream − using (var decompressStream = new GZipStream(inputStream, CompressionMode.Decompress)) { // read decompressed data } Using GZipStream for File Compression To compress a ...

Read More

What is late binding in C#?

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

Late binding in C# refers to the process where the decision of which method to call is made at runtime rather than compile time. This is also known as dynamic polymorphism, where the actual method implementation is determined by the object type at runtime, not by the reference type. Late binding is implemented using virtual methods in base classes and override methods in derived classes. When a virtual method is called through a base class reference, the runtime determines which derived class method to execute based on the actual object type. How Late Binding Works In late ...

Read More
Showing 7731–7740 of 25,466 articles
« Prev 1 772 773 774 775 776 2547 Next »
Advertisements