Programming Articles

Page 800 of 2547

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 464 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 162 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

C# program to check if a value is in an array

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

Use the Array.Exists method to check if a value is in an array or not. This method returns a boolean value indicating whether the specified element exists in the array. Syntax Following is the syntax for Array.Exists method − public static bool Exists(T[] array, Predicate match) Parameters array − The one-dimensional array to search. match − A predicate that defines the conditions of the element to search for. Return Value Returns true if the array contains an element that matches the conditions defined by the ...

Read More

C# Program to remove a node at the beginning of a Linked List

Samual Sam
Samual Sam
Updated on 17-Mar-2026 256 Views

To remove a node at the beginning of a LinkedList in C#, use the RemoveFirst() method. This method removes the first node from the LinkedList and automatically adjusts the internal structure. Syntax Following is the syntax for the RemoveFirst() method − linkedList.RemoveFirst(); This method removes the first node and does not return any value. If the LinkedList is empty, it throws an InvalidOperationException. How It Works When you call RemoveFirst(), the LinkedList performs the following operations − RemoveFirst() Operation ...

Read More
Showing 7991–8000 of 25,466 articles
« Prev 1 798 799 800 801 802 2547 Next »
Advertisements