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
Articles on Trending Technologies
Technical articles with clear explanations and examples
Tuple Rest Property in C#
The Rest property in C# tuples allows you to create tuples with eight or more elements by nesting additional tuple objects. When a tuple has more than seven elements, the eighth and subsequent elements are stored in the Rest property as a nested tuple. Syntax The general structure for an 8-element tuple using the Rest property is − Tuple Where TRest is another tuple type containing the remaining elements. You can create such tuples using Tuple.Create() − var myTuple = Tuple.Create(item1, item2, item3, item4, item5, item6, item7, item8); How the ...
Read MoreHow to call Math Operations using Delegates in C#?
To understand how to call Math Operations using Delegates in C#, let us see an example wherein we will perform mathematical operations like division, multiplication, and addition using delegates. A delegate in C# is a type that represents references to methods with a specific signature. Syntax Following is the syntax for declaring a delegate that can reference mathematical methods − delegate returnType DelegateName(parameters); Following is the syntax for assigning methods to a delegate − DelegateName delegateInstance = MethodName; // or DelegateName delegateInstance = new DelegateName(MethodName); Using Delegates for Basic Math ...
Read MoreHow to calculate the power exponent value using C#?
To calculate the power exponent value in C#, use the Math.Pow() method from the System namespace. This method raises a number to a specified power and returns the result as a double. Syntax Following is the syntax for the Math.Pow() method − public static double Pow(double x, double y) Parameters x − The base number (of type double). y − The exponent (of type double). Return Value Returns a double value representing x raised to the power of y (xy). Using Math.Pow() with Integers ...
Read MoreWhat is a managed code in C#?
Managed code in C# is code whose execution is managed by the Common Language Runtime (CLR). The CLR provides automatic memory management, type safety, exception handling, and garbage collection. When you write C# code, it gets compiled into Intermediate Language (IL) code, which is then executed by the CLR. Unlike unmanaged code (such as C/C++), managed code runs within the .NET runtime environment, which handles low-level operations automatically. This makes development safer and more efficient by reducing common programming errors like memory leaks and buffer overflows. How Managed Code Works The execution process of managed code follows ...
Read MoreInheritance vs Composition in C#
In C#, there are two fundamental ways to establish relationships between classes: inheritance and composition. Inheritance creates an "IS-A" relationship where a derived class inherits behavior from a base class, while composition creates a "HAS-A" relationship where one class contains instances of other classes as components. Inheritance Inheritance allows you to designate that a new class should inherit the members of an existing class. The existing class is called the base class, and the new class is referred to as the derived class. Inheritance implements the IS-A relationship. For example, mammal IS-A animal, dog IS-A mammal, hence dog ...
Read MoreC# program to find additional values in two lists
Finding additional values between two lists is a common requirement in C# programming. This involves identifying elements that exist in one list but not in another. The Except() method from LINQ provides an efficient way to find the difference between two collections. Syntax The Except() method returns elements from the first sequence that are not present in the second sequence − IEnumerable result = list1.Except(list2); To find differences in both directions, you can use − var onlyInList1 = list1.Except(list2); var onlyInList2 = list2.Except(list1); Using Except() to Find Additional Values ...
Read MoreFibonacci Series in C#
The Fibonacci series is a sequence of numbers where each number is the sum of the two preceding numbers. The series typically starts with 0 and 1, producing the sequence: 0, 1, 1, 2, 3, 5, 8, 13, 21, and so on. In C#, there are multiple ways to generate the Fibonacci series, including iterative and recursive approaches. Fibonacci Series Pattern 0 1 1 2 3 ...
Read MoreC# object serialization
Object serialization in C# is the process of converting an object into a stream of bytes for storage or transmission. The serialized data can be saved to files, databases, or sent over a network, and later deserialized back into objects. C# provides several approaches for serialization, including binary serialization, XML serialization, and JSON serialization. Binary serialization preserves the complete object state and type information. Syntax For binary serialization using BinaryFormatter − [Serializable] public class ClassName { // class members } BinaryFormatter formatter = new BinaryFormatter(); formatter.Serialize(stream, objectInstance); For deserialization ...
Read MoreHow to perform Division of Exponents of Same Base using C#?
When dividing exponents with the same base, we use the mathematical rule: a^m ÷ a^n = a^(m-n). This means we subtract the exponent in the denominator from the exponent in the numerator while keeping the base unchanged. In C#, we can implement this rule by subtracting the exponents and then using Math.Pow() to calculate the final result. Mathematical Rule The division rule for exponents with the same base is − a^m ÷ a^n = a^(m-n) For example: 10^10 ÷ 10^8 = 10^(10-8) = 10^2 = 100 Division of ...
Read MoreLocal Inner Class in C#
A nested class in C# is a class declared inside another enclosing class. The nested class is a member of its outer class and can access the outer class's private members, while the outer class cannot directly access the nested class's members without creating an instance. Nested classes provide better organization and encapsulation by grouping related functionality together. They are particularly useful when a class is only meaningful within the context of another class. Syntax Following is the syntax for declaring a nested class − class OuterClass { // outer class ...
Read More