Articles on Trending Technologies

Technical articles with clear explanations and examples

Default Interface Methods in C#

Siva Sai
Siva Sai
Updated on 17-Mar-2026 699 Views

Default interface methods are a game-changing feature introduced in C# 8.0 that allow developers to add new methods to an interface without breaking existing implementations. This feature enables interface evolution while maintaining backward compatibility with existing code. Syntax Following is the syntax for defining a default interface method − public interface IInterfaceName { void MethodName() { // default implementation } } A class can use the default implementation or override it − public class ClassName : IInterfaceName { ...

Read More

C# String.IsNormalized Method

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 282 Views

The String.IsNormalized() method in C# is used to indicate whether this string is in a particular Unicode normalization form. Unicode normalization ensures that text with the same meaning has a consistent binary representation, which is important for string comparison and text processing. Syntax The syntax is as follows − public bool IsNormalized(); public bool IsNormalized(System.Text.NormalizationForm normalizationForm); Parameters normalizationForm − A System.Text.NormalizationForm enumeration value that specifies the Unicode normalization form to check against. The possible values are: FormC − Canonical Decomposition followed by Canonical Composition FormD − Canonical Decomposition FormKC − Compatibility ...

Read More

Gets or sets the value at the specified key in StringDictionary in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 161 Views

The StringDictionary class in C# provides an indexer property that allows you to get or set values using a key-based approach. This indexer uses the syntax dictionary[key] to access or modify values at the specified key. Syntax Following is the syntax for getting or setting values using the indexer − // Getting a value string value = stringDictionary[key]; // Setting a value stringDictionary[key] = newValue; Parameters key − A string that represents the key to locate in the StringDictionary. value − The string value to associate with the specified key when ...

Read More

How to get the thread ID from a thread in C#?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 17-Mar-2026 4K+ Views

A thread is defined as the execution path of a program. Each thread defines a unique flow of control. If your application involves complicated and time-consuming operations, then it is often helpful to set different execution paths or threads, with each thread performing a particular job. Threads are lightweight processes. One common example of use of thread is implementation of concurrent programming by modern operating systems. Use of threads saves wastage of CPU cycle and increase efficiency of an application. In C#, the System.Threading.Thread class is used for working with threads. It allows creating and accessing individual threads ...

Read More

How to display methods and properties using reflection in C#?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 17-Mar-2026 349 Views

Reflection is the process of examining and describing the metadata of types, methods, and properties in a code at runtime. The System.Reflection namespace enables you to obtain data about loaded assemblies, the elements within them like classes, methods, and value types. The most commonly used classes in System.Reflection include Assembly, AssemblyName, ConstructorInfo, MethodInfo, ParameterInfo, EventInfo, PropertyInfo, and MemberInfo. Syntax Following is the syntax for getting type information using reflection − TypeInfo typeInfo = typeof(ClassName).GetTypeInfo(); IEnumerable properties = typeInfo.DeclaredProperties; IEnumerable methods = typeInfo.DeclaredMethods; Using Reflection to Display Properties and Methods Reflection allows you ...

Read More

Delegates vs Interfaces in C#

Siva Sai
Siva Sai
Updated on 17-Mar-2026 2K+ Views

Delegates and interfaces are both powerful constructs in C# that allow for flexible and extensible code. While they serve different purposes, they can sometimes be used to achieve similar ends, leading to confusion about when to use one over the other. This article will elucidate the differences and similarities between delegates and interfaces, and provide guidelines for their use. Syntax Following is the syntax for declaring a delegate − public delegate returnType DelegateName(parameters); Following is the syntax for declaring an interface − public interface IInterfaceName { returnType MethodName(parameters); } ...

Read More

Remove all even numbers from an array in C#

AYUSH MISHRA
AYUSH MISHRA
Updated on 17-Mar-2026 19K+ Views

Removing all even numbers from an array is a common programming task that involves filtering out numbers divisible by 2. In C#, we can accomplish this using various approaches such as iterative methods, LINQ, or recursion to create a new array containing only odd numbers. Problem Description We are given an array and need to remove all the even numbers from it. The resulting array should only contain odd numbers. An even number is any integer that is divisible by 2 (i.e., number % 2 == 0), while an odd number leaves a remainder of 1 when divided ...

Read More

TimeSpan.FromMilliseconds() Method in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 661 Views

The TimeSpan.FromMilliseconds() method in C# is used to return a TimeSpan that represents a specified number of milliseconds. This static method is particularly useful when you need to create time intervals based on millisecond values, such as delays, timeouts, or performance measurements. Syntax Following is the syntax for the TimeSpan.FromMilliseconds() method − public static TimeSpan FromMilliseconds(double value); Parameters The method accepts one parameter − value − A double that represents the number of milliseconds. It can be positive, negative, or zero. Return Value The method returns a TimeSpan ...

Read More

How to read a CSV file and store the values into an array in C#?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 17-Mar-2026 29K+ Views

A CSV file is a comma-separated values file that stores data in a tabular format. Most business organizations use CSV files to store and exchange structured data because of their simplicity and wide compatibility. In C#, we can read CSV files using the StreamReader class along with File.OpenRead() method. The data can then be parsed and stored in arrays or collections for further processing. Syntax Following is the basic syntax for reading a CSV file − StreamReader reader = new StreamReader(File.OpenRead(filePath)); while (!reader.EndOfStream) { var line = reader.ReadLine(); ...

Read More

How to perform a left outer join using linq extension methods in C#?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 17-Mar-2026 2K+ Views

In LINQ, a Left Outer Join includes all elements from the left collection and matching elements from the right collection. When there's no match in the right collection, the result still includes the left element with null values for the right side. This is different from an Inner Join, which only includes matching elements from both collections. Left Outer Join ensures that no records from the left collection are lost, even when they don't have corresponding matches in the right collection. Syntax The Left Outer Join pattern using LINQ extension methods follows this structure − ...

Read More
Showing 10271–10280 of 61,297 articles
Advertisements