Programming Articles

Page 820 of 2547

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 667 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 405 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

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

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

The Count property of the SortedList class in C# returns the number of key-value pairs stored in the collection. This read-only property is useful for determining the size of the sorted list and performing operations that depend on the collection's current size. Syntax Following is the syntax for accessing the Count property − int count = sortedList.Count; Return Value The Count property returns an int value representing the total number of key-value pairs currently stored in the SortedList. Example The following example demonstrates how to use the Count property to get ...

Read More

What are rvalue and lvalue in C#?

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

In C#, expressions are categorized into two types based on their position and usage in assignment operations: lvalue and rvalue. Understanding these concepts helps in writing correct assignment statements and understanding compiler errors. Definitions lvalue − An expression that represents a memory location and can appear on either the left-hand or right-hand side of an assignment. The term "lvalue" means "left value". rvalue − An expression that represents a value and can only appear on the right-hand side of an assignment. The term "rvalue" means "right value". ...

Read More
Showing 8191–8200 of 25,466 articles
« Prev 1 818 819 820 821 822 2547 Next »
Advertisements