Articles on Trending Technologies

Technical articles with clear explanations and examples

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

Sort KeyValuePairs in C#

Arjun Thakur
Arjun Thakur
Updated on 17-Mar-2026 976 Views

The KeyValuePair structure in C# represents a key-value pair that can be stored in collections. When working with lists of KeyValuePairs, you often need to sort them based on either the key or value. C# provides several approaches to accomplish this sorting. Syntax Following is the syntax for sorting KeyValuePairs using the Sort() method with a lambda expression − myList.Sort((x, y) => x.Value.CompareTo(y.Value)); // Sort by Value (ascending) myList.Sort((x, y) => y.Value.CompareTo(x.Value)); // Sort by Value (descending) myList.Sort((x, y) => x.Key.CompareTo(y.Key)); // Sort by Key (ascending) Following ...

Read More

C# Queryable Max Method

karthikeya Boyini
karthikeya Boyini
Updated on 17-Mar-2026 255 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

KeyNotFoundException in C#

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

The KeyNotFoundException in C# is thrown when you attempt to access a key that does not exist in a Dictionary collection. This exception occurs specifically when using the indexer syntax dictionary[key] to retrieve a value. When KeyNotFoundException Occurs This exception is thrown in the following scenarios − Accessing a Dictionary using dict[key] where the key doesn't exist Using the indexer on collections like SortedDictionary or SortedList with non-existent keys Attempting to retrieve values from key-value collections without checking key existence Dictionary Key Access ...

Read More

C# Queryable Min Method

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

The Min() method in C# is used to find the minimum value from a sequence. When used with AsQueryable(), it creates a queryable data source that can be efficiently processed using LINQ expressions. Syntax Following is the syntax for the Queryable Min() method − public static TSource Min(this IQueryable source); public static TResult Min(this IQueryable source, Expression selector); Parameters source: The IQueryable sequence to find the minimum value in. selector: A function to extract a value from each element (optional). Return Value Returns the minimum value in the sequence. ...

Read More

System.ArrayCopyTo() vs System.ArrayClone() in C#

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

The CopyTo() and Clone() methods in C# are used to copy array elements, but they work differently. The CopyTo() method copies elements from one array to an existing array at a specified index, while Clone() creates a new array that is a shallow copy of the original array. Understanding the difference between these methods is crucial for proper array manipulation and memory management in C# applications. Syntax Following is the syntax for the CopyTo() method − sourceArray.CopyTo(destinationArray, startIndex); Following is the syntax for the Clone() method − object clonedArray = sourceArray.Clone(); ...

Read More

C# orderby Keyword

George John
George John
Updated on 17-Mar-2026 258 Views

The orderby keyword in C# is used to sort data in LINQ queries. It allows you to sort collections in either ascending or descending order based on one or more criteria. Syntax Following is the syntax for using orderby in LINQ queries − from element in collection orderby element ascending select element; For descending order − from element in collection orderby element descending select element; Multiple sorting criteria can be applied using commas − from element in collection orderby element.Property1, element.Property2 descending select element; Using orderby ...

Read More
Showing 10861–10870 of 61,297 articles
Advertisements