Articles on Trending Technologies

Technical articles with clear explanations and examples

Print with your own font using C#

Chandu yadav
Chandu yadav
Updated on 17-Mar-2026 561 Views

To print with your own font in C#, you need to construct two essential objects: a FontFamily object and a Font object. The FontFamily object sets the typeface like Arial, Times New Roman, etc., whereas the Font object defines the size, style, and unit of measurement for the font. Syntax Following is the syntax for creating a FontFamily object − FontFamily fontFamily = new FontFamily("FontName"); Following is the syntax for creating a Font object − Font font = new Font(fontFamily, size, style, unit); Parameters The Font constructor accepts the ...

Read More

Date format validation using C# Regex

karthikeya Boyini
karthikeya Boyini
Updated on 17-Mar-2026 17K+ Views

Date format validation in C# ensures that user input matches the expected date format before processing. The most reliable approach is using the DateTime.TryParseExact method, which validates both the format and the actual date values. For more complex pattern matching, Regular Expressions (Regex) can also be used. Syntax Following is the syntax for DateTime.TryParseExact method − bool DateTime.TryParseExact(string s, string format, IFormatProvider provider, DateTimeStyles style, out DateTime result) Following is the syntax for Regex date validation − Regex regex = new Regex(@"pattern"); bool isMatch = regex.IsMatch(dateString); ...

Read More

C# Program to convert integer array to string array

karthikeya Boyini
karthikeya Boyini
Updated on 17-Mar-2026 2K+ Views

Converting an integer array to a string array is a common task in C# programming. The most efficient approach is using the Array.ConvertAll() method, which applies a conversion function to each element in the source array and returns a new array of the target type. Syntax Following is the syntax for Array.ConvertAll() method − string[] result = Array.ConvertAll(sourceArray, converter); Parameters sourceArray − The source integer array to convert converter − A lambda expression or method that converts each element Return Value Returns a new string ...

Read More

C# Program to find the longest string from an array of strings using Lambda Expression

Chandu yadav
Chandu yadav
Updated on 17-Mar-2026 1K+ Views

Lambda expressions in C# provide a concise way to write anonymous functions. When working with arrays of strings, you can use lambda expressions with LINQ methods like Aggregate() to perform operations such as finding the longest string. In this example, we'll demonstrate how to find the longest string from an array using the Aggregate() method with a lambda expression. Syntax The Aggregate() method with lambda expression follows this syntax − collection.Aggregate(seed, (accumulator, next) => condition ? next : accumulator, result => transformation) Where − seed − Initial value for comparison accumulator ...

Read More

Dictionary.Clear Method in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 3K+ Views

The Dictionary.Clear() method in C# removes all key/value pairs from the Dictionary. This method is useful when you need to empty a dictionary completely while keeping the dictionary object itself for future use. Syntax public void Clear(); Parameters The Clear() method takes no parameters. Return Value The Clear() method does not return any value. It has a void return type. Dictionary.Clear() Operation Before Clear() Key1: Value1 Key2: Value2 Key3: Value3 ...

Read More

DateTime.IsDaylightSavingTime() Method in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 466 Views

The DateTime.IsDaylightSavingTime() method in C# determines whether a specific DateTime instance falls within the daylight saving time range for the current time zone. This method returns true if the date and time are within the DST period, and false otherwise. This method is particularly useful when working with time-sensitive applications that need to account for seasonal time changes in different regions. Syntax Following is the syntax for the DateTime.IsDaylightSavingTime() method − public bool IsDaylightSavingTime(); Return Value The method returns a bool value − true − if the DateTime instance is ...

Read More

Uri.Equals(Object) Method in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 165 Views

The Uri.Equals(Object) method in C# compares two Uri instances for equality. This method performs a case-sensitive comparison of the complete URI strings, including scheme, host, port, path, query, and fragment components. Syntax Following is the syntax − public override bool Equals(object comparand); Parameters comparand − The Uri instance or object to compare with the current instance. Can be null. Return Value Returns true if the specified object is a Uri instance equivalent to the current Uri instance; otherwise, false. If the comparand is null or not a Uri object, the method ...

Read More

What are I/O classes in C#?

Chandu yadav
Chandu yadav
Updated on 17-Mar-2026 1K+ Views

The System.IO namespace in C# provides a comprehensive collection of classes for performing input/output operations. These classes enable you to work with files, directories, streams, and other data sources efficiently. I/O classes in C# are categorized into several groups based on their functionality − File and Directory Classes These classes provide static methods for basic file and directory operations − using System; using System.IO; class Program { public static void Main() { // File class example string fileName = ...

Read More

Print Single and Multiple variable in C#

Samual Sam
Samual Sam
Updated on 17-Mar-2026 10K+ Views

In C#, displaying variable values to the console is fundamental for debugging and output purposes. You can print single or multiple variables using various methods with Console.WriteLine(). Syntax Following is the syntax for printing a single variable − Console.WriteLine(variable); Console.WriteLine("Text: " + variable); Following is the syntax for printing multiple variables − Console.WriteLine("Values: {0} {1}", var1, var2); Console.WriteLine($"Values: {var1} {var2}"); Printing a Single Variable You can print a single variable by passing it directly to Console.WriteLine() or by concatenating it with text using the + operator − ...

Read More

C# program to list the difference between two lists

Samual Sam
Samual Sam
Updated on 17-Mar-2026 2K+ Views

To find the difference between two lists in C#, you can use the Except() method from LINQ. This method returns elements from the first list that are not present in the second list, effectively giving you the set difference. Syntax Following is the syntax for using Except() method to find list difference − IEnumerable result = list1.Except(list2); Where list1 is the source list and list2 contains elements to exclude from the result. Using Except() Method The Except() method performs a set difference operation, returning elements that exist in the first collection but ...

Read More
Showing 10661–10670 of 61,297 articles
Advertisements