Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Programming Articles
Page 86 of 2547
What is C# Programming?
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 MoreC# Exponential ("E") Format Specifier
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 MoreCompute modulus division by a power-of-2-number in C#
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 MoreWhat is a parameterized constructor in C# programs?
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 MoreWhat is Cast Operator () in C#?
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 MoreHow to find the length of jagged array using a property?
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 MoreC# Fixed-Point ("F") Format Specifier
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 MoreCompressing and Decompressing files in C#
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 MoreWhat is late binding in C#?
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 MoreWhat is difference between internal and private modifiers in C#?
The internal and private access modifiers in C# control the visibility and accessibility of class members. Understanding their differences is crucial for designing well-structured applications with proper encapsulation. The internal modifier allows access within the same assembly, while private restricts access to the same class only. Both serve different purposes in controlling member visibility. Syntax Following is the syntax for internal access modifier − internal dataType memberName; internal void MethodName() { } Following is the syntax for private access modifier − private dataType memberName; private void MethodName() { } ...
Read More