Server Side Programming Articles

Page 804 of 2109

C# program to check for a string that contains all vowels

karthikeya Boyini
karthikeya Boyini
Updated on 17-Mar-2026 686 Views

A C# program to check if a string contains all vowels involves examining the string to identify which vowels (a, e, i, o, u) are present. This is useful for word games, text analysis, or linguistic applications where you need to verify vowel completeness. Syntax The basic approach uses LINQ methods to filter and check for vowels − var vowels = str.Where(ch => "aeiouAEIOU".Contains(ch)).Distinct(); To check if all five vowels are present − bool hasAllVowels = vowels.Count() == 5; Using LINQ to Find All Vowels This approach uses the ...

Read More

How to convert a number from Decimal to Binary using recursion in C#?

karthikeya Boyini
karthikeya Boyini
Updated on 17-Mar-2026 524 Views

Converting a decimal number to binary using recursion in C# involves repeatedly dividing the number by 2 and collecting the remainders. The recursive approach breaks down the problem into smaller subproblems until the base case is reached. Syntax Following is the basic syntax for the recursive binary conversion method − public void ConvertToBinary(int decimalNumber) { if (decimalNumber > 0) { ConvertToBinary(decimalNumber / 2); Console.Write(decimalNumber % 2); } } How It ...

Read More

How to Convert Hex String to Hex Number in C#?

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

In C#, converting a hexadecimal string to its numeric value is a common operation. Hexadecimal strings represent numbers in base 16 using digits 0-9 and letters A-F. C# provides several methods to convert hex strings to different numeric types depending on your needs. Syntax Following is the syntax for converting hex strings using different methods − Convert.ToInt32(hexString, 16) Convert.ToSByte(hexString, 16) int.Parse(hexString, NumberStyles.HexNumber) Using Convert.ToInt32() Method The most commonly used method is Convert.ToInt32() which converts a hex string to a 32-bit signed integer − using System; public class Program { ...

Read More

C# program to check whether a given string is Heterogram or not

karthikeya Boyini
karthikeya Boyini
Updated on 17-Mar-2026 457 Views

A Heterogram is a string that contains no duplicate letters. Each character in the string appears exactly once. For example, words like "mobile", "cry", and "laptop" are heterograms because no letter is repeated. Examples of Heterograms mobile - No repeated letters cry - All unique letters laptop - Each letter appears once Algorithm The algorithm uses an integer array to track which letters have been encountered. For each character in the string − Convert the character to an array index using str[i] - ...

Read More

How to check if two Strings are anagrams of each other using C#?

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

An anagram is a word or phrase formed by rearranging the letters of another word or phrase, using all the original letters exactly once. For example, "silent" and "listen" are anagrams because they contain the same letters in different arrangements. In C#, there are several approaches to check if two strings are anagrams. The most common method is to sort the characters of both strings and compare them for equality. Using Array.Sort() Method The simplest approach is to convert both strings to character arrays, sort them, and then compare the sorted arrays − ...

Read More

C# program to find Union of two or more Dictionaries

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

The union of two or more dictionaries combines all unique keys from the dictionaries. In C#, you can find the union using HashSet and the UnionWith() method to merge dictionary keys, or use LINQ methods to combine both keys and values. Syntax Following is the syntax for finding union of dictionary keys using HashSet − HashSet unionKeys = new HashSet(dict1.Keys); unionKeys.UnionWith(dict2.Keys); Following is the syntax for merging dictionary values using LINQ − var unionDict = dict1.Union(dict2).ToDictionary(kvp => kvp.Key, kvp => kvp.Value); Using HashSet for Key Union The most straightforward ...

Read More

C# program to find Union of two or more Lists

Arjun Thakur
Arjun Thakur
Updated on 17-Mar-2026 1K+ Views

The Union operation in C# combines multiple lists while removing duplicate elements. The Union() method from LINQ returns distinct elements from both collections, preserving the order of first occurrence. Syntax Following is the syntax for using the Union() method − var result = list1.Union(list2); For multiple lists, chain the Union operations − var result = list1.Union(list2).Union(list3); Using Union() Method with Two Lists The Union()

Read More

C# program to concat two or more Lists

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

In C#, you can concatenate multiple List objects using the Concat() method from LINQ. This method creates a new sequence that contains all elements from the original lists in order without modifying the original lists. Syntax Following is the syntax for concatenating lists using the Concat() method − var result = list1.Concat(list2); For multiple lists, you can chain the Concat() calls − var result = list1.Concat(list2).Concat(list3); Using Concat() to Merge Two Lists Example using System; using System.Collections.Generic; using System.Linq; public class Demo { ...

Read More

C# program to find common values from two or more Lists

George John
George John
Updated on 17-Mar-2026 540 Views

Finding common values from two or more Lists in C# is a frequent requirement in programming. The Intersect() method from LINQ provides an efficient way to identify elements that exist in multiple collections. Syntax Following is the syntax for using Intersect() method − var result = list1.Intersect(list2); For multiple lists, chain the Intersect() method − var result = list1.Intersect(list2).Intersect(list3); Using Intersect() with Two Lists The Intersect() method returns elements that appear in both lists. It automatically removes duplicates and maintains the order from the first list − Example ...

Read More

Union Method in C#

Arjun Thakur
Arjun Thakur
Updated on 17-Mar-2026 980 Views

The Union method in C# is a LINQ extension method that returns the unique elements from both collections. It combines two sequences and automatically removes duplicate values, ensuring each element appears only once in the result. Syntax Following is the syntax for the Union method − public static IEnumerable Union( this IEnumerable first, IEnumerable second ) Parameters first − The first sequence to merge. second − The second sequence to merge. Return Value Returns an IEnumerable containing ...

Read More
Showing 8031–8040 of 21,090 articles
« Prev 1 802 803 804 805 806 2109 Next »
Advertisements