Server Side Programming Articles

Page 768 of 2109

What are user defined data types in C#?

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

User-defined data types in C# allow developers to create custom types beyond the built-in primitive types. The main user-defined data types in C# are structures, enumerations, classes, interfaces, and delegates. This article focuses on structures and enumerations as fundamental user-defined types. Structure In C#, a structure is a value type data type that helps you group related data of various types into a single unit. The struct keyword is used for creating a structure. Syntax public struct StructName { // fields, properties, methods, constructors public dataType field1; ...

Read More

What is aggregation in C#?

Arjun Thakur
Arjun Thakur
Updated on 17-Mar-2026 535 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

What is finally statement in C#?

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

The finally statement in C# is used to execute a given set of statements, whether an exception is thrown or not thrown. For example, if you open a file, it must be closed whether an exception is raised or not. The error handling blocks are implemented using the try, catch, and finally keywords. The finally block is guaranteed to execute, making it ideal for cleanup operations like closing files, database connections, or releasing resources. Syntax Following is the syntax for the finally statement − try { // code that might throw an ...

Read More

What does Array.IsFixedSize property of array class do in C# ?

Chandu yadav
Chandu yadav
Updated on 17-Mar-2026 367 Views

The IsFixedSize property of the ArrayList class is used to determine whether an ArrayList has a fixed size. When IsFixedSize returns true, you cannot add or remove elements, but you can still modify existing elements. When it returns false, the ArrayList can grow or shrink dynamically. Regular ArrayLists created with the default constructor always return false for IsFixedSize because they can dynamically resize. However, you can create fixed-size wrappers using ArrayList.FixedSize() method. Syntax Following is the syntax to check the IsFixedSize property − bool isFixed = arrayList.IsFixedSize; Following is the syntax to create ...

Read More

What is overloading in C#?

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

C# provides two techniques to implement static polymorphism − Function overloading Operator overloading Function Overloading Function overloading in C# allows multiple methods with the same name but different parameters within the same class. The compiler determines which method to call based on the number, types, and order of arguments passed. Syntax Following is the syntax for function overloading − public returnType MethodName(parameter1) { } public returnType MethodName(parameter1, parameter2) { } public returnType MethodName(differentType parameter) { } Method Overloading Resolution Add(int, ...

Read More

What does Array.Length property of array class do in C#?

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

The Array.Length property in C# is used to get the total number of elements in an array. This property returns an integer value representing the array's size, which is essential for array manipulation and iteration. Syntax Following is the syntax for using the Array.Length property − int length = arrayName.Length; Return Value The Length property returns an int value representing the total number of elements in the array. Using Array.Length with Array.CreateInstance The following example demonstrates how to use Array.Length with dynamically created arrays − using System; class ...

Read More

What does Array.LongLength property of array class do in C#?

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

The Array.LongLength property in C# gets a 64-bit integer (long) that represents the total number of elements in all dimensions of an array. This property is particularly useful when working with very large arrays that might exceed the range of a 32-bit integer. Syntax Following is the syntax for using the LongLength property − long totalElements = arrayName.LongLength; Return Value The property returns a long value representing the total number of elements across all dimensions of the array. Single-Dimensional Array Example For a single-dimensional array, LongLength returns the same value as ...

Read More

How to calculate the power exponent value using C#?

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

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 More

Fibonacci Series in C#

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

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 More

What is the use of 'new' keyword in C#?

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

The new keyword in C# serves multiple important purposes. It is primarily used to create new instances of classes, allocate memory for arrays, and hide inherited members from base classes. Syntax Following is the syntax for creating object instances using new − ClassName objectName = new ClassName(); Following is the syntax for creating arrays using new − dataType[] arrayName = new dataType[size]; Following is the syntax for hiding base class members using new − public new void MethodName() { // hides the base class method ...

Read More
Showing 7671–7680 of 21,090 articles
« Prev 1 766 767 768 769 770 2109 Next »
Advertisements