Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Articles on Trending Technologies
Technical articles with clear explanations and examples
How to replace line breaks in a string in C#?
In C#, you often need to remove or replace line breaks from strings when processing text data. Line breaks can appear as (line feed), \r (carriage return), or \r (Windows-style line endings). This article demonstrates different approaches to handle line breaks in strings. Common Line Break Characters Different operating systems use different line break characters − − Line Feed (LF), used on Unix/Linux/Mac \r − Carriage Return (CR), used on older Mac systems \r − Carriage Return + Line Feed (CRLF), used on Windows Line Break Types ...
Read MoreGet the TypeCode for value type Char in C#
The TypeCode for a char value type in C# can be obtained using the GetTypeCode() method. This method returns TypeCode.Char, which is an enumeration value that identifies the char data type. The GetTypeCode() method is inherited from the IConvertible interface and provides a way to determine the underlying type of a value at runtime. Syntax Following is the syntax to get the TypeCode for a char value − TypeCode typeCode = charVariable.GetTypeCode(); Return Value The method returns TypeCode.Char for char data types, which is part of the TypeCode enumeration. Using GetTypeCode() ...
Read MoreHow to get all elements of a List that match the conditions specified by the predicate in C#?
To get all elements of a List that match specific conditions, C# provides the FindAll method which accepts a predicate − a delegate that defines the filtering criteria. This method returns a new List containing only the elements that satisfy the condition. Syntax Following is the syntax for using FindAll with a predicate − List result = list.FindAll(predicate); The predicate can be defined as a method, lambda expression, or anonymous delegate − // Method predicate private static bool MethodName(T item) { return condition; } // Lambda expression predicate ...
Read MoreExecuting C# code in Linux
The .NET ecosystem was traditionally limited to Windows, but Microsoft's introduction of Mono changed this landscape. Mono enables the execution of .NET applications on Linux systems, making them run as if they were native Linux packages rather than Windows executable files. What is Mono? Mono is an open-source, cross-platform implementation of Microsoft's .NET Framework. It allows developers to run .NET applications on various platforms including Linux and macOS. Mono provides a complete development stack that supports Windows Forms, LINQ, XML web services, ADO.NET, and ASP.NET using the same CLR namespaces. Cross-Platform .NET with ...
Read MoreHow to find items in one list that are not in another list in C#?
Finding items in one list that are not present in another list is a common task in C# programming. LINQ provides multiple approaches to solve this problem, with the Except() method being the most straightforward for simple data types and the Where() clause being more flexible for complex objects. Syntax Using the Except() method for simple types − var result = list1.Except(list2); Using Where() clause with All() for complex objects − var result = list1.Where(item1 => list2.All(item2 => condition)); Using Except() Method The Except() method is a LINQ set ...
Read MoreCheck whether the specified Unicode character is a letter or a decimal digit in C#
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 MoreHow to get the HashCode of the tuple in C#?
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 MoreCheck whether the Unicode character is a lowercase letter in C#
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 MoreDifference between Method Overriding and Method Hiding in C#
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 MoreHow can we return null from a generic method in C#?
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