Server Side Programming Articles

Page 816 of 2109

C# Program to split parts in a Windows directory

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

A Windows directory path consists of multiple parts separated by backslashes (\). In C#, you can split a directory path into its individual components using the Split() method with the backslash character as the delimiter. This technique is useful for extracting specific parts of a path, validating directory structures, or processing file paths programmatically. Syntax Following is the syntax for splitting a Windows directory path − string[] parts = directoryPath.Split(''); You can also use the verbatim string literal to define the path − string path = @"C:\Users\Documents\MyFile.txt"; Using Split() ...

Read More

C# Program to write a number in hexadecimal format

Ankith Reddy
Ankith Reddy
Updated on 17-Mar-2026 642 Views

Converting numbers to hexadecimal format in C# can be accomplished using various format specifiers. Hexadecimal is a base-16 number system commonly used in programming for representing binary data in a more readable format. Syntax Following are the main hexadecimal format specifiers in C# − {0:x} // lowercase hexadecimal {0:X} // uppercase hexadecimal {0:x8} // lowercase with 8 digits (zero-padded) {0:X8} // uppercase with 8 digits (zero-padded) You can also use the ToString() method with format specifiers − number.ToString("x") // ...

Read More

Tuple.Create method in C#

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

The Tuple.Create method in C# is a convenient way to create tuple objects without explicitly specifying their types. The method automatically infers the types from the provided arguments, making tuple creation more concise and readable. Syntax Following is the syntax for using Tuple.Create method − var tupleName = Tuple.Create(item1, item2, ...); The method can accept up to 8 parameters of different types − Tuple.Create(T1 item1); Tuple.Create(T1 item1, T2 item2); // ... up to 8 items Creating Basic Tuples Example Here we create a tuple with a string and ...

Read More

Set 6-item tuple in C#'

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

A 6-item tuple in C# is a data structure that can hold six values of different or same data types. Tuples are useful when you need to return multiple values from a method or group related data together without creating a separate class. Syntax Following is the syntax for creating a 6-item tuple using the Tuple class − var tuple = new Tuple(item1, item2, item3, item4, item5, item6); Alternatively, you can use the modern tuple syntax with parentheses − var tuple = (item1, item2, item3, item4, item5, item6); Using Traditional ...

Read More

C# Program to check if a character is a whitespace character

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

In C#, a whitespace character includes spaces, tabs, newlines, and other invisible characters used for formatting text. The char.IsWhiteSpace() method provides an easy way to identify these characters programmatically. Syntax Following is the syntax for using char.IsWhiteSpace() method − bool result = char.IsWhiteSpace(character); Parameters The method takes a single parameter − character − The character to be tested for whitespace. Return Value Returns true if the character is a whitespace character; otherwise, returns false. Using char.IsWhiteSpace() with Different Whitespace Characters The method recognizes various types of ...

Read More

C# program to check whether two sequences are the same or not

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

The SequenceEqual method in C# is a LINQ extension method that determines whether two sequences are equal by comparing their elements using the default equality comparer. It returns true if the sequences have the same length and corresponding elements are equal, otherwise it returns false. Syntax Following is the syntax for using SequenceEqual method − bool result = sequence1.SequenceEqual(sequence2); You can also use a custom equality comparer − bool result = sequence1.SequenceEqual(sequence2, comparer); Parameters sequence2 − The sequence to compare with the current sequence. comparer ...

Read More

Group by Operator in C#

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

The Group By operator in C# is used to group elements in a collection based on a specified key. It separates the results into groups where each group contains elements that share the same key value. Syntax Following is the syntax for using Group By with LINQ query syntax − var result = from element in collection group element by keySelector; Following is the syntax for using Group By with method syntax − var result = collection.GroupBy(keySelector); ...

Read More

Round a number to the nearest even number in C#

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

The MidpointRounding.ToEven option is used with rounding methods in C# to round a number to the nearest even number when the fractional part is exactly 0.5. This is also known as banker's rounding or round half to even. Syntax Following is the syntax for rounding to the nearest even number − decimal.Round(value, digits, MidpointRounding.ToEven) Math.Round(value, digits, MidpointRounding.ToEven) Parameters value − The decimal or double number to be rounded digits − The number of decimal places in the return value MidpointRounding.ToEven − Rounds to the nearest even number ...

Read More

Decimal type in C#

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

The decimal type in C# is a 128-bit data type designed for financial and monetary calculations that require high precision. Unlike float and double, the decimal type provides exact decimal representation without rounding errors, making it ideal for applications involving currency and precise arithmetic operations. Syntax Following is the syntax for declaring decimal variables − decimal variableName = value; decimal variableName = valueM; // M or m suffix required for literals The M or m suffix is required when assigning decimal literals to distinguish them from double values − decimal price = ...

Read More

Decimal constants in C#

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

The decimal type in C# provides built-in constants to retrieve the minimum and maximum possible values for decimal numbers. These constants are useful for validation, range checking, and initialization purposes. Syntax Following is the syntax for declaring a decimal constant − decimal variableName = value M; Following is the syntax for accessing decimal constants − decimal.MaxValue // Maximum possible decimal value decimal.MinValue // Minimum possible decimal value Decimal Constants The decimal type provides two important constants − decimal.MaxValue − Returns the largest possible decimal ...

Read More
Showing 8151–8160 of 21,090 articles
« Prev 1 814 815 816 817 818 2109 Next »
Advertisements