karthikeya Boyini

karthikeya Boyini

1,421 Articles Published

Articles by karthikeya Boyini

Page 12 of 143

C# Linq Intersect Method

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

The Intersect() method in C# LINQ is used to find common elements between two collections. It returns a new sequence containing elements that exist in both the source collection and the specified collection, with duplicates automatically removed. Syntax Following is the syntax for the Intersect() method − public static IEnumerable Intersect( this IEnumerable first, IEnumerable second ) With a custom equality comparer − public static IEnumerable Intersect( this IEnumerable first, IEnumerable second, ...

Read More

What is the Capacity property of an ArrayList class in C#?

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

The Capacity property in the ArrayList class gets or sets the number of elements that the ArrayList can contain. This property represents the internal array size, which is automatically managed by the ArrayList to optimize performance. The capacity is always greater than or equal to the count of elements. When elements are added and the capacity is exceeded, the ArrayList automatically doubles its capacity to accommodate more elements. Syntax Following is the syntax for accessing the Capacity property − arrayListName.Capacity You can also set the capacity explicitly − arrayListName.Capacity = newCapacityValue; ...

Read More

Retrieving Elements from Collection in C#

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

Collections in C# provide various ways to retrieve elements. The List collection is one of the most commonly used collections that allows you to access elements by index, retrieve specific elements, or iterate through all elements. Syntax Following is the syntax for accessing elements by index − ElementType element = list[index]; Following is the syntax for using foreach to iterate through all elements − foreach (ElementType item in list) { // process item } Using Index-Based Access You can retrieve elements from a List collection using ...

Read More

Bitwise right shift operators in C#

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

The bitwise right shift operator (>>) in C# moves the bits of the left operand to the right by the number of positions specified by the right operand. This operation effectively divides the number by powers of 2. Syntax Following is the syntax for the bitwise right shift operator − result = operand >> numberOfPositions; How It Works When you right shift a binary number, each bit moves to the right by the specified number of positions. Vacant positions on the left are filled with zeros for positive numbers and ones for negative ...

Read More

What is the Count property of BitArray class in C#?

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

The Count property of the BitArray class in C# returns the total number of elements (bits) in the BitArray. This is a read-only property that gives you the size of the BitArray, which is determined when the BitArray is created. Syntax Following is the syntax for accessing the Count property − int count = bitArray.Count; Return Value The Count property returns an int value representing the number of bits in the BitArray. Using Count Property with BitArray Let us first create a BitArray and then use the Count property to get ...

Read More

Virtual vs Sealed vs New vs Abstract in C#

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

In C#, virtual, sealed, new, and abstract are important keywords that control method inheritance and overriding behavior. Understanding these modifiers is crucial for implementing proper object-oriented design patterns and controlling how classes interact through inheritance. Virtual The virtual keyword allows a method in a base class to be overridden in derived classes. When a method is declared as virtual, derived classes can provide their own implementation using the override keyword. Syntax public virtual ReturnType MethodName() { // base implementation } Example using System; class Animal { ...

Read More

C# Queryable Max Method

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

The Queryable.Max() method in C# returns the maximum value from a sequence of numeric values. It operates on IQueryable collections and provides query optimization for data sources like Entity Framework. Syntax Following is the syntax for the Max() method − public static TSource Max(this IQueryable source) public static TResult Max(this IQueryable source, Expression selector) Parameters source − An IQueryable sequence of values to determine the maximum value of. selector − A transform function to apply to each element (optional overload). Return Value Returns the maximum ...

Read More

How to use the GetType method of array class in C#?

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

The GetType() method in C# is inherited from the Object class and returns the exact runtime type of the current instance. When used with arrays, it provides information about the array's type, including its element type and dimensions. Syntax Following is the syntax for using the GetType() method − Type type = arrayInstance.GetType(); Return Value The method returns a Type object that represents the exact runtime type of the current instance. Using GetType() with Arrays When applied to arrays, GetType() returns the array type, which includes information about the element type ...

Read More

C# Program to Convert Integer to String

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

To convert an integer to string in C#, you can use several methods. The most common approach is the ToString() method, which provides a simple and direct way to convert any integer value to its string representation. Syntax Following is the syntax for using ToString() method − string result = number.ToString(); Alternative syntax using Convert.ToString() method − string result = Convert.ToString(number); Using ToString() Method The ToString() method is called on the integer variable to convert it to a string − using System; class Program { ...

Read More

What is the base class for all data types in C#.NET?

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

Object is the base class for all data types in C#. The Object Type is the ultimate base class for all data types in C# Common Type System (CTS). The object is an alias for System.Object class. When a value type is converted to object type, it is called boxing and on the other hand, when an object type is converted to a value type, it is called unboxing. Syntax Following is the syntax for declaring an object variable − object variableName; object variableName = value; Following is the syntax for boxing and ...

Read More
Showing 111–120 of 1,421 articles
« Prev 1 10 11 12 13 14 143 Next »
Advertisements