How to access array elements using a pointer in C#?

karthikeya Boyini
Updated on 17-Mar-2026 07:04:35

4K+ Views

In C#, accessing array elements using pointers requires understanding the key differences between arrays and pointers. An array name and a pointer to the same data type are not the same variable type. For example, int *p and int[] p represent different types. You can increment a pointer variable because it's not fixed in memory, but an array address is fixed in memory and cannot be incremented directly. To access array elements using pointers in C#, you must use unsafe code and the fixed statement to pin the array in memory temporarily. Syntax Following is the syntax ... Read More

Multiple Where clause in C# Linq

karthikeya Boyini
Updated on 17-Mar-2026 07:04:35

5K+ Views

In C# LINQ, you can apply multiple where clauses to filter collections based on different conditions. Each additional where clause further narrows down the results, creating a logical AND relationship between the conditions. Syntax There are two main approaches to using multiple where clauses − Query Syntax with Multiple Where Clauses: var result = from item in collection where condition1 where condition2 ... Read More

What is the Keys property of Hashtable class in C#?

Chandu yadav
Updated on 17-Mar-2026 07:04:35

171 Views

The Keys property of the Hashtable class in C# returns an ICollection containing all the keys in the hashtable. This property is useful for iterating through all keys or performing operations on the key collection without accessing the values. Syntax Following is the syntax for accessing the Keys property − public virtual ICollection Keys { get; } Return Value The Keys property returns an ICollection object that contains all the keys in the hashtable. The order of keys is not guaranteed as hashtables do not maintain insertion order. Using Keys Property to ... Read More

Decimal.ToSingle() Method in C#

AmitDiwan
Updated on 17-Mar-2026 07:04:35

203 Views

The Decimal.ToSingle() method in C# is used to convert the value of the specified decimal to the equivalent single-precision floating-point number (float). This method is useful when you need to convert high-precision decimal values to float for mathematical operations or when interfacing with APIs that require float parameters. Syntax Following is the syntax − public static float ToSingle(decimal val); Parameters val − The decimal number to convert to a single-precision floating-point number. Return Value Returns a single-precision floating-point number (float) that is equivalent to the specified decimal value. Using Decimal.ToSingle() ... Read More

How to use C# BinaryWriter class?

Samual Sam
Updated on 17-Mar-2026 07:04:35

276 Views

The BinaryWriter class in C# is used to write binary data to a stream in a binary format. It is part of the System.IO namespace and provides methods to write primitive data types like integers, strings, doubles, and booleans directly to a stream as binary data. Unlike text-based writing, BinaryWriter stores data in its native binary representation, making it more efficient for storage and faster to read back using BinaryReader. Syntax Following is the syntax for creating a BinaryWriter instance − BinaryWriter writer = new BinaryWriter(stream); Following is the syntax for writing data ... Read More

C# program to find common elements in three arrays using sets

Chandu yadav
Updated on 17-Mar-2026 07:04:35

625 Views

In C#, you can find common elements in three arrays efficiently using HashSet collections. A HashSet provides fast lookups and set operations, making it ideal for finding intersections between collections of data. The HashSet class offers built-in methods like IntersectWith() that can perform set operations directly, eliminating the need for complex loops and comparisons. Syntax Following is the syntax for creating a HashSet from an array − var hashSet = new HashSet(array); Following is the syntax for finding intersection using IntersectWith() − hashSet1.IntersectWith(hashSet2); hashSet1.IntersectWith(hashSet3); Finding ... Read More

What is the difference between virtual and abstract functions in C#?

Samual Sam
Updated on 17-Mar-2026 07:04:35

5K+ Views

In C#, both virtual and abstract methods enable polymorphism but serve different purposes. Virtual methods provide a default implementation that can be overridden, while abstract methods have no implementation and must be overridden by derived classes. Understanding the difference between these two concepts is crucial for implementing proper inheritance hierarchies and achieving runtime polymorphism in your applications. Syntax Following is the syntax for declaring a virtual method − public virtual returnType MethodName() { // default implementation } Following is the syntax for declaring an abstract method − ... Read More

C# Enum IsDefined Method

Chandu yadav
Updated on 17-Mar-2026 07:04:35

3K+ Views

The Enum.IsDefined method in C# determines whether a specified value exists within a given enumeration. It returns true if the value is found, either as an integral value or its corresponding string name, and false otherwise. Syntax Following is the syntax for the Enum.IsDefined method − public static bool IsDefined(Type enumType, object value) Parameters enumType − The type of the enumeration to check against. value − The value to look for in the enumeration (can be an integer or string). Return Value Returns true if the specified value exists ... Read More

C# Nested Classes

Arjun Thakur
Updated on 17-Mar-2026 07:04:35

2K+ Views

A nested class is a class declared inside another enclosing class. It is a member of its enclosing class, and nested classes can access private members of their enclosing class. However, the enclosing class cannot directly access private members of the nested class without creating an instance. Syntax Following is the syntax for declaring a nested class − public class OuterClass { // outer class members public class NestedClass { // nested class members } } ... Read More

Char.Parse(String) Method in C#

AmitDiwan
Updated on 17-Mar-2026 07:04:35

4K+ Views

The Char.Parse(String) method in C# is used to convert the value of the specified string to its equivalent Unicode character. This method is particularly useful when you need to extract a single character from a string representation. Syntax Following is the syntax − public static char Parse(string s); Parameters s − A string that contains a single character, or null. Return Value Returns a Unicode character that is equivalent to the sole character in s. Examples Example 1: Parsing a Letter Character The following ... Read More

Advertisements