Articles on Trending Technologies

Technical articles with clear explanations and examples

How do you find the length of an array in C#?

George John
George John
Updated on 17-Mar-2026 18K+ Views

To find the length of an array in C#, use the Length property (not a method). The Length property returns the total number of elements in the array as an integer value. Syntax Following is the syntax for using the Length property − int length = arrayName.Length; Parameters arrayName − The array whose length you want to find Return Value The Length property returns an int value representing the total number of elements in the array. Example Let us see an example − using System; ...

Read More

String Literal Vs String Object in C#

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

In C#, strings can be created using string literals or as string objects. Understanding the difference between these two approaches is important for memory management and performance optimization. String Literals String literals are constants enclosed in double quotes "" or prefixed with @"" for verbatim strings. They are stored in a special area of memory called the string pool, where identical string values are shared to save memory. Syntax Following is the syntax for string literals − string variableName = "string value"; string verbatimString = @"string with multiple lines or special characters"; ...

Read More

Ulong type in C#

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

The ulong type in C# is a 64-bit unsigned integer that represents the System.UInt64 structure. It can store values from 0 to 18, 446, 744, 073, 709, 551, 615, making it ideal for storing large positive numbers without sign considerations. The ulong keyword is an alias for System.UInt64 and is part of C#'s built-in value types. Since it's unsigned, it cannot store negative values but has twice the positive range compared to long. Syntax Following is the syntax for declaring a ulong variable − ulong variableName = value; You can also use the ...

Read More

AsEnumerable() in C#

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

The AsEnumerable() method in C# is used to cast a specific type to its IEnumerable equivalent. It is an extension method from the System.Linq namespace that helps when you need to treat a collection as a basic enumerable sequence, often to force LINQ to Objects behavior over LINQ to SQL or Entity Framework queries. Syntax Following is the syntax for using AsEnumerable() − public static IEnumerable AsEnumerable(this IEnumerable source) Usage example − var enumerable = collection.AsEnumerable(); Parameters source − The sequence to type as IEnumerable. Return ...

Read More

BigInteger Class in C#

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

The BigInteger class in C# is designed to handle arbitrarily large integers that exceed the limits of standard integer types. It is part of the System.Numerics namespace and provides support for mathematical operations on very large numbers without overflow. Unlike built-in integer types like int or long, BigInteger can represent integers of any size, limited only by available memory. This makes it ideal for cryptographic calculations, mathematical computations, and scenarios requiring precise arithmetic with large numbers. Syntax The BigInteger structure declaration − [SerializableAttribute] public struct BigInteger : IFormattable, IComparable, IComparable, IEquatable Creating a ...

Read More

How do you find the number of dimensions of an array in C#?

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

To find the number of dimensions of an array in C#, use the Rank property. This property returns an integer representing the total number of dimensions in the array. Syntax Following is the syntax for getting the number of dimensions − int dimensions = arr.Rank; For getting the length of specific dimensions, use the GetLength() method − int lengthOfDimension = arr.GetLength(dimensionIndex); Using Rank Property The Rank property works with single-dimensional, multi-dimensional, and jagged arrays − using System; class Program { static void Main() ...

Read More

ContainsKey in C#

Ankith Reddy
Ankith Reddy
Updated on 17-Mar-2026 2K+ Views

The ContainsKey method in C# is a Dictionary method that checks whether a specified key exists in the dictionary. It returns a boolean value − true if the key is found, false otherwise. This method is essential for safe dictionary operations to avoid exceptions when accessing non-existent keys. Syntax Following is the syntax for the ContainsKey method − public bool ContainsKey(TKey key) Parameters key − The key to locate in the dictionary. This parameter cannot be null for reference types. Return Value Returns true if the dictionary ...

Read More

C# Linq Intersect Method

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

How to use the directory class in C#?

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

The Directory class in C# is used to manipulate the directory structure. It provides static methods to create, move, delete, and query directories without needing to create an instance of the class. The Directory class is part of the System.IO namespace and offers essential functionality for working with file system directories programmatically. Syntax Following is the basic syntax for using Directory class methods − Directory.MethodName(path); Directory.MethodName(path, parameters); Common Directory Class Methods Method Description CreateDirectory(String) Creates all directories and subdirectories in the specified path ...

Read More

Binary search in C#

Ravi Ranjan
Ravi Ranjan
Updated on 17-Mar-2026 12K+ Views

The binary search algorithm works on the divide and conquer principle as it keeps dividing the array in half before searching. To search for an element in an array using binary search, the array must be sorted. In the sorted array, we find the middle element and compare it with the element that has to be searched, and based on the comparison, we either search in the left sub-array, right sub-array, or return the middle element. In this article, we are given a sorted array of integers, and our task is to search for the given target element ...

Read More
Showing 10831–10840 of 61,297 articles
Advertisements