Programming Articles

Page 83 of 2547

DateTimeOffset.CompareTo() Method in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 151 Views

The DateTimeOffset.CompareTo() method in C# compares the current DateTimeOffset object to a specified DateTimeOffset object and indicates whether the current object is earlier than, the same as, or later than the second DateTimeOffset object. It returns an integer value based on the comparison result − < 0 − If this object is earlier than the specified value 0 − If this object is the same as the specified value > 0 − If this object is later than the specified value Syntax Following is the syntax − public int CompareTo(DateTimeOffset value); ...

Read More

DateTimeOffset.ToFileTime() Method in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 139 Views

The DateTimeOffset.ToFileTime() method in C# is used to convert the value of the current DateTimeOffset object to a Windows file time. The method returns an Int64 value representing the current DateTimeOffset object, expressed as a Windows file time. A Windows file time is a 64-bit value that represents the number of 100-nanosecond intervals that have elapsed since 12:00 midnight, January 1, 1601 A.D. (UTC). This format is commonly used by Windows file systems to store file timestamps. Syntax Following is the syntax − public long ToFileTime(); Return Value The method returns a ...

Read More

What are the main parts of a C# program?

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

The main parts of a C# program include − Namespace declaration A class Class methods Class attributes A Main method Statements and Expressions Comments Understanding these components is essential for writing effective C# programs. Each part serves a specific purpose in organizing and executing your code. Basic C# Program Structure The following example demonstrates a simple C# program with all the essential parts − using System; namespace Demo { class Program { // Class attribute (field) ...

Read More

An array of streams in C#

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

An array of streams in C# refers to using arrays or collections along with stream objects like StreamWriter and StreamReader to perform file I/O operations. This approach is commonly used when you need to write multiple data items from an array to a file or read file content into an array structure. Syntax Following is the syntax for writing array data to a file using StreamWriter − using (StreamWriter writer = new StreamWriter("filename.txt")) { foreach (dataType item in arrayName) { writer.WriteLine(item); ...

Read More

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 242 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 141 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 170 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
Showing 821–830 of 25,467 articles
« Prev 1 81 82 83 84 85 2547 Next »
Advertisements