Articles on Trending Technologies

Technical articles with clear explanations and examples

Int16.GetTypeCode Method in C# with Examples

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 169 Views

The Int16.GetTypeCode() method in C# is used to return the TypeCode for value type Int16. This method is part of the IConvertible interface and helps identify the underlying data type at runtime. The TypeCode enumeration provides a way to categorize the data types supported by the Common Language Runtime (CLR). For Int16 values, this method always returns TypeCode.Int16. Syntax Following is the syntax − public TypeCode GetTypeCode(); Return Value This method returns TypeCode.Int16, which is the enumerated constant representing the Int16 type. Using GetTypeCode() with Int16 Values Example Let ...

Read More

C# program to check if a string contains any special character

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

To check if a string contains any special character in C#, you can use the Char.IsLetterOrDigit method. This method returns false for any character that is not a letter or digit, which means it's a special character. Special characters include symbols like @, #, $, %, &, punctuation marks, and whitespace characters that are not alphanumeric. Syntax Following is the syntax for checking if a character is a letter or digit − bool Char.IsLetterOrDigit(char c) To check for special characters, use the negation operator − if (!Char.IsLetterOrDigit(character)) { ...

Read More

C# Linq Skip() Method

George John
George John
Updated on 17-Mar-2026 3K+ Views

The Skip() method in C# LINQ is used to skip a specified number of elements from the beginning of a sequence and return the remaining elements. This method is particularly useful when you need to bypass certain elements in a collection before processing the rest. Syntax Following is the syntax for the Skip() method − public static IEnumerable Skip( this IEnumerable source, int count ) Parameters source − The sequence to return elements from. count − The number of elements ...

Read More

Write a C# program to find GCD and LCM?

Ankith Reddy
Ankith Reddy
Updated on 17-Mar-2026 1K+ Views

In C#, finding the GCD (Greatest Common Divisor) and LCM (Least Common Multiple) of two numbers is a common mathematical programming task. The GCD is the largest positive integer that divides both numbers without remainder, while the LCM is the smallest positive integer that both numbers can divide evenly. These calculations are frequently used in mathematical applications, fraction simplification, and solving problems involving ratios and proportions. Mathematical Relationship There's an important mathematical relationship between GCD and LCM − GCD(a, b) × LCM(a, b) = a × b This means once we find the ...

Read More

Case-insensitive Dictionary in C#

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

A case-insensitive Dictionary in C# allows you to perform key lookups without considering the case of string keys. This means keys like "cricket", "CRICKET", and "Cricket" are treated as identical. This is particularly useful when dealing with user input or data from external sources where case consistency cannot be guaranteed. Syntax To create a case-insensitive Dictionary, use the StringComparer.OrdinalIgnoreCase parameter in the constructor − Dictionary dict = new Dictionary(StringComparer.OrdinalIgnoreCase); You can also use other string comparers − // Culture-insensitive comparison Dictionary dict1 = new Dictionary(StringComparer.InvariantCultureIgnoreCase); // Current culture ignore case Dictionary ...

Read More

C# Numeric ("N") Format Specifier

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

The numeric (N) format specifier converts a number to a string with thousands separators and decimal places. It follows the pattern -d, ddd, ddd.ddd… where the minus sign appears for negative numbers, digits are grouped with commas, and decimal places are included. Syntax Following is the syntax for using the numeric format specifier − number.ToString("N") // Default 2 decimal places number.ToString("N0") // No decimal places number.ToString("Nn") ...

Read More

C# program to check password validity

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

While creating a password, you may have seen validation requirements on websites that ensure a password is strong and secure. Common password requirements include − Minimum 8 characters and maximum 14 characters At least one lowercase letter No whitespace characters At least one uppercase letter At least one special character Let us create a complete password validation program that checks all these conditions systematically. Complete Password Validation Program using System; using System.Linq; class PasswordValidator { public static bool IsValidPassword(string passwd) { ...

Read More

C# Program to count the number of lines in a file

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

Counting the number of lines in a file is a common task in C# programming. This can be accomplished using several methods from the System.IO namespace. The most straightforward approach is to use the File.ReadAllLines() method combined with the Length property. Using File.ReadAllLines() Method The File.ReadAllLines() method reads all lines from a file into a string array, and then we can use the Length property to count the total number of lines − Example using System; using System.IO; public class Program { public static void Main() { ...

Read More

C# Linq SkipLast Method

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

The SkipLast() method in C# LINQ is used to skip a specified number of elements from the end of a sequence and return the remaining elements. This method is particularly useful when you need to exclude the last few items from a collection. Syntax Following is the syntax for the SkipLast() method − public static IEnumerable SkipLast( this IEnumerable source, int count ) Parameters source − The sequence to skip elements from. count − The number of elements to skip from the end ...

Read More

How to split a string with a string delimiter in C#?

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

String splitting in C# is a common operation used to divide a string into substrings based on specified delimiters. The Split() method provides multiple overloads to handle different types of delimiters including characters, strings, and arrays. Syntax Following are the common syntax forms for splitting strings − // Split by single character string[] result = str.Split(', '); // Split by character array char[] delimiters = {', ', ';', '|'}; string[] result = str.Split(delimiters); // Split by string delimiter string[] result = str.Split(new string[] {"||"}, StringSplitOptions.None); Using Character Delimiters The simplest way ...

Read More
Showing 10951–10960 of 61,297 articles
Advertisements