Programming Articles

Page 709 of 2547

Check whether the specified Unicode character is a letter or a decimal digit in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 236 Views

To check whether the specified Unicode character is a letter or a decimal digit in C#, use the Char.IsLetterOrDigit() method. This method returns true if the character is a letter (uppercase or lowercase) or a decimal digit (0-9), and false otherwise. Syntax Following is the syntax for the Char.IsLetterOrDigit() method − public static bool IsLetterOrDigit(char c) Parameters c: The Unicode character to evaluate. Return Value Returns true if the character is a letter or decimal digit; otherwise, false. Using IsLetterOrDigit with Decimal Digits Example ...

Read More

How to get the HashCode of the tuple in C#?

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 244 Views

To get the HashCode of a tuple in C#, you can use the GetHashCode() method. This method returns an integer hash code that represents the tuple's value. Tuples with identical values will have the same hash code, while tuples with different values will typically have different hash codes. Syntax Following is the syntax for getting the hash code of a tuple − int hashCode = tuple.GetHashCode(); Return Value The GetHashCode() method returns a 32-bit signed integer that serves as a hash code for the tuple. Equal tuples will always return the same hash ...

Read More

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

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 311 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
Nitin Sharma
Updated on 17-Mar-2026 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
Nizamuddin Siddiqui
Updated on 17-Mar-2026 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
AmitDiwan
Updated on 17-Mar-2026 135 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
Nizamuddin Siddiqui
Updated on 17-Mar-2026 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
AmitDiwan
Updated on 17-Mar-2026 191 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
Nizamuddin Siddiqui
Updated on 17-Mar-2026 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

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

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 332 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
Showing 7081–7090 of 25,466 articles
« Prev 1 707 708 709 710 711 2547 Next »
Advertisements