Check whether the Unicode character is a lowercase letter in C#

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

310 Views

To check whether a Unicode character is a lowercase letter in C#, we use the Char.IsLower() method. This method examines the Unicode character and returns true if it represents a lowercase letter according to Unicode standards, and false otherwise. Syntax Following is the syntax for the Char.IsLower() method − public static bool IsLower(char c) Parameters c − The Unicode character to evaluate Return Value The method returns a bool value − true if the character is a lowercase letter false if the character is not a lowercase ... Read More

Difference between Method Overriding and Method Hiding in C#

Nitin Sharma
Updated on 17-Mar-2026 07:04:36

3K+ Views

In C#, there are two mechanisms for redefining or providing new implementation of a method from a parent class in its child class: Method Overriding and Method Hiding. Understanding the difference between these concepts is crucial for implementing proper inheritance and polymorphism. Method overriding uses the override keyword and enables runtime polymorphism, while method hiding uses the new keyword and provides compile-time method resolution. Syntax Following is the syntax for method overriding − public class BaseClass { public virtual void Method() { } } public class DerivedClass : BaseClass { ... Read More

How can we return null from a generic method in C#?

Nizamuddin Siddiqui
Updated on 17-Mar-2026 07:04:36

2K+ Views

Generics in C# allow us to define classes and methods with placeholders for types, which are replaced with specific types at compile time. However, returning null from a generic method requires special handling because the compiler cannot determine whether the generic type T is a reference type or value type. When you try to return null directly from a generic method, you'll encounter a compilation error because null cannot be assigned to value types like int, double, etc. The Problem Here's what happens when we try to return null directly from a generic method − ... Read More

Compare this instance is equal to a specified object or Int64 in C#

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

133 Views

The Equals() method in C# is used to compare whether the current instance of a long (Int64) is equal to a specified object or another Int64 value. This method performs value-based comparison and returns a boolean result. Syntax Following is the syntax for the Equals() method − public bool Equals(long value) public override bool Equals(object obj) Parameters value − A long value to compare with the current instance. obj − An object to compare with the current instance. Return Value Returns true if the current ... Read More

What is the use of yield return in C#?

Nizamuddin Siddiqui
Updated on 17-Mar-2026 07:04:36

3K+ Views

The yield return keyword in C# enables lazy evaluation and custom iteration over collections. When you use yield return, the method becomes an iterator that returns values one at a time, pausing execution between each return and resuming where it left off when the next value is requested. Syntax Following is the syntax for using yield return − public static IEnumerable MethodName() { // some logic yield return value; // more logic yield return anotherValue; } You can ... Read More

Get the hash code for the current Int64 instance in C#

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

190 Views

The GetHashCode() method in C# returns a hash code for the current Int64 instance. This method is inherited from the Object class and is commonly used in hash-based collections like Dictionary and HashSet to efficiently store and retrieve values. Hash codes are 32-bit integers that provide a quick way to compare objects for equality. Two equal Int64 values will always have the same hash code, but different values may occasionally produce the same hash code (called a collision). Syntax Following is the syntax for getting the hash code of an Int64 value − public override ... Read More

What is the difference between Last() and LastOrDefault() in Linq C#?

Nizamuddin Siddiqui
Updated on 17-Mar-2026 07:04:36

1K+ Views

Both Last() and LastOrDefault() are LINQ extension methods that retrieve the last element from a sequence. The key difference is how they handle empty sequences or no matching elements: Last() throws an InvalidOperationException when no element is found, while LastOrDefault() returns the default value for the type (null for reference types, 0 for integers, etc.). Syntax Following is the syntax for Last() method − public static T Last(this IEnumerable source); public static T Last(this IEnumerable source, Func predicate); Following is the syntax for LastOrDefault() method − public static T LastOrDefault(this IEnumerable source); ... Read More

C# Program to Check if an Array is Sorted

AYUSH MISHRA
Updated on 17-Mar-2026 07:04:36

5K+ Views

We are given an array, and we need to check whether the array is sorted or not. The array can be sorted in either ascending or descending order. In this article, we will discuss different approaches to check if an array is sorted using C#. Problem Examples Input: array = {1, 2, 3, 4, 5} Output: True Explanation: The array is sorted in ascending order. Input: array = {29, 28, 27, 26, 25, 24} Output: True Explanation: The array is sorted in descending order. Input: array = {12, 10, 19, 11, 9} Output: False Explanation: The ... Read More

Check whether the specified Unicode character is a punctuation mark in C#

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

331 Views

The Char.IsPunctuation() method in C# determines whether a specified Unicode character is classified as a punctuation mark. This method returns true if the character belongs to any punctuation category, otherwise it returns false. Punctuation marks include characters like periods, commas, semicolons, exclamation points, question marks, brackets, and other symbols used for punctuation in text. Syntax Following is the syntax for the Char.IsPunctuation() method − public static bool IsPunctuation(char c) Parameters c − The Unicode character to evaluate. Return Value Returns true if the character is a ... Read More

How to remove element from the specified index of the List in C#?

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

311 Views

To remove an element from a specified index in a List in C#, you use the RemoveAt() method. This method removes the element at the given index and automatically shifts all subsequent elements one position to the left. Syntax Following is the syntax for the RemoveAt() method − list.RemoveAt(int index); Parameters index − The zero-based index of the element to remove. Must be a valid index (0 ≤ index < Count). Using RemoveAt() with String List The following example demonstrates removing an element at index 5 from a list ... Read More

Advertisements