Articles on Trending Technologies

Technical articles with clear explanations and examples

Sorting a String in C#

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

Sorting a string array in C# is accomplished using the Array.Sort() method, which arranges elements in alphabetical order. This method modifies the original array and uses lexicographic comparison by default. Syntax Following is the basic syntax for sorting a string array − Array.Sort(arrayName); For custom sorting, you can use an overloaded version − Array.Sort(arrayName, StringComparer.OrdinalIgnoreCase); Using Array.Sort() for String Arrays The Array.Sort() method sorts string arrays in ascending alphabetical order. Here's how it works − using System; public class Program { public static ...

Read More

Full Date Short Time ("f") Format Specifier in C#

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

The Full Date Short Time ("f") format specifier in C# represents a combination of the long date ("D") and short time ("t") patterns. It displays the complete date information along with hours and minutes in a readable format. This format specifier is culture-sensitive and will display dates according to the specified culture's formatting conventions. Syntax Following is the syntax for using the "f" format specifier − DateTime.ToString("f") DateTime.ToString("f", CultureInfo.CreateSpecificCulture("culture-code")) Using "f" Format Specifier with Default Culture Example using System; class Demo { static void Main() { ...

Read More

What is the IsFixedSize property of Hashtable class in C#?

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

The IsFixedSize property of the Hashtable class in C# returns a bool value indicating whether the Hashtable has a fixed size. When this property returns false, you can add or remove elements. When it returns true, the size is fixed and you cannot add or remove elements. For a regular Hashtable created using the default constructor, IsFixedSize always returns false, meaning it can grow dynamically as you add elements. Syntax Following is the syntax to check if a Hashtable has a fixed size − bool isFixed = hashtable.IsFixedSize; Return Value The IsFixedSize ...

Read More

DateTimeOffset.ToLocalTime() Method in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 228 Views

The DateTimeOffset.ToLocalTime() method in C# converts a DateTimeOffset object to the local time zone of the system where the code is running. This method adjusts both the time value and the offset to match the local time zone. Syntax Following is the syntax for the ToLocalTime() method − public DateTimeOffset ToLocalTime(); Return Value This method returns a new DateTimeOffset object that represents the same moment in time but adjusted to the local time zone. The offset will reflect the local system's time zone offset from UTC. Using ToLocalTime() with Current Time ...

Read More

How to compile and execute C# programs on Mac OS?

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

To compile and execute C# programs on Mac OS, you need an Integrated Development Environment (IDE) or compiler toolchain. Mac OS offers several excellent options for C# development, ranging from full-featured IDEs to lightweight editors and command-line tools. The most popular and recommended approach is using Visual Studio for Mac or the newer Visual Studio Code with the C# extension. Additionally, you can use the .NET CLI for command-line compilation and execution. Using Visual Studio for Mac Visual Studio for Mac is a native macOS IDE specifically designed for .NET development. It provides IntelliSense, debugging tools, and ...

Read More

Convert.ToSingle Method in C#

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

The Convert.ToSingle() method in C# converts a specified value to a single-precision floating-point number (float). This method can convert various data types including boolean, integer, string, and other numeric types to a 32-bit floating-point representation. Syntax Following is the syntax for the Convert.ToSingle() method − public static float ToSingle(object value); public static float ToSingle(bool value); public static float ToSingle(int value); public static float ToSingle(string value); Parameters value − The value to be converted to a single-precision floating-point number. Can be of various types including bool, int, string, double, decimal, etc. ...

Read More

Check if both halves of the string have same set of characters in C#

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

To check if both halves of a string have the same set of characters in C#, we need to split the string into two equal halves and compare the character frequencies in each half. This problem is useful for validating palindromic properties and string pattern matching. Algorithm The approach uses character frequency counting − Create two frequency arrays to count characters in each half Iterate from both ends of the string toward the center Count character occurrences in the left half and right half Compare the frequency arrays to determine if both halves contain the same ...

Read More

How to create 2-tuple or pair tuple in C#?

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 421 Views

The Tuple class in C# represents a 2-tuple, also known as a pair. A tuple is a data structure that contains a sequence of elements of different types. The 2-tuple holds exactly two values that can be accessed using Item1 and Item2 properties. 2-tuples are useful when you need to return two values from a method or group two related values together without creating a separate class. Syntax Following is the syntax for creating a 2-tuple − Tuple tuple = new Tuple(value1, value2); Accessing tuple elements − var firstValue = tuple.Item1; ...

Read More

DateTimeOffset.ToOffset() Method in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 724 Views

The DateTimeOffset.ToOffset() method in C# is used to convert a DateTimeOffset object to a different time zone offset while preserving the same absolute point in time. This method adjusts the local time component to match the new offset, ensuring the UTC time remains unchanged. Syntax Following is the syntax − public DateTimeOffset ToOffset(TimeSpan offset) Parameters offset: A TimeSpan representing the time zone offset to convert to. The offset must be between -14 and +14 hours. Return Value Returns a new DateTimeOffset object with the specified offset, representing the same moment in ...

Read More

How to copy or clone a C# list?

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

Copying or cloning a C# list means creating a duplicate of the original list. There are several approaches to accomplish this, each suitable for different scenarios. The choice depends on whether you need a shallow copy or deep copy, and the target data structure. Syntax Following are the common syntaxes for copying a list − // Using constructor List newList = new List(originalList); // Using ToList() method List newList = originalList.ToList(); // Using CopyTo() method T[] array = new T[originalList.Count]; originalList.CopyTo(array); Using List Constructor The most straightforward way to clone a ...

Read More
Showing 10381–10390 of 61,299 articles
Advertisements