Articles on Trending Technologies

Technical articles with clear explanations and examples

DateTime.AddDays() Method in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 10K+ Views

The DateTime.AddDays() method in C# is used to add the specified number of days to the value of this instance. This method returns a new DateTime object without modifying the original instance, as DateTime is immutable. Syntax Following is the syntax − public DateTime AddDays(double days); Parameters days − A number of whole and fractional days. The value parameter can be negative or positive. Return Value This method returns a new DateTime object whose value is the sum of the date and time represented by this instance and the ...

Read More

Print number with commas as 1000 separators in C#

Giri Raju
Giri Raju
Updated on 17-Mar-2026 2K+ Views

In C#, you can format numbers with commas as thousand separators using various approaches. The most common and efficient methods involve using format strings with the ToString() method or composite formatting. Syntax Following is the syntax for formatting numbers with thousand separators − number.ToString("N") // Standard numeric format number.ToString("#, ##0.##") // Custom format with commas string.Format("{0:N}", number) // Composite formatting Using Standard Numeric Format ("N") The "N" format specifier automatically adds thousand separators and formats the number according to the current ...

Read More

C# Hexadecimal ("X") Format Specifier

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

The hexadecimal ("X") format specifier is used to convert a number to a string of hexadecimal digits. The case of the format specifier determines whether hexadecimal digits greater than 9 are displayed in uppercase or lowercase. Use "X" for uppercase hexadecimal letters (A, B, C, D, E, F) and "x" for lowercase hexadecimal letters (a, b, c, d, e, f). Syntax Following is the syntax for using the hexadecimal format specifier − number.ToString("X") // uppercase number.ToString("x") // lowercase number.ToString("X4") // uppercase with minimum 4 ...

Read More

DateTime.AddHours() Method in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 7K+ Views

The DateTime.AddHours() method in C# is used to add the specified number of hours to the value of this instance. This method returns a new DateTime object, leaving the original instance unchanged. Syntax Following is the syntax − public DateTime AddHours(double hrs); Parameters hrs − A number of hours to be added. The value can be positive (to add hours) or negative (to subtract hours). Fractional values represent parts of an hour. Return Value Returns a new DateTime object that represents the date and time that results from adding the specified ...

Read More

How to compare two arrays in C#?

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

Comparing arrays in C# can be done using several approaches. The most common and efficient method is using the SequenceEqual() method from LINQ, but you can also compare arrays manually using loops or other techniques. Syntax Following is the syntax for using SequenceEqual() to compare two arrays − bool result = array1.SequenceEqual(array2); Following is the syntax for manual comparison using a loop − bool areEqual = true; for (int i = 0; i < array1.Length; i++) { if (array1[i] != array2[i]) { ...

Read More

Print first m multiples of n in C#

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

To print the first m multiples of a given number n in C#, we use a loop to iterate and calculate each multiple. This is useful for displaying multiplication tables or generating sequences. Syntax Following is the basic syntax for printing multiples using a loop − for (int i = 1; i

Read More

Differences between C++ and C#

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

C++ is a statically typed, compiled, general-purpose, case-sensitive programming language that supports procedural, object-oriented, and generic programming paradigms. It is regarded as a middle-level language because it combines both high-level and low-level language features. C# is a simple, modern, general-purpose, object-oriented programming language developed by Microsoft within its .NET initiative, led by Anders Hejlsberg. Both languages share some similarities but differ significantly in design philosophy and implementation. Key Differences Between C++ and C# Memory Management C++ uses manual memory management where developers must explicitly allocate and deallocate memory using new and delete operators. C# features automatic ...

Read More

Convert.ToDouble(String, IFormatProvider) Method in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 2K+ Views

The Convert.ToDouble(String, IFormatProvider) method in C# converts a string representation of a number to an equivalent double-precision floating-point number using specified culture-specific formatting information. This method is particularly useful when working with numeric strings that follow different regional formatting conventions. Syntax Following is the syntax − public static double ToDouble(string value, IFormatProvider provider); Parameters value − A string that contains the number to convert. provider − An object that supplies culture-specific formatting information. If null, the current culture is used. Return Value Returns a double-precision floating-point number equivalent to ...

Read More

static keyword in C#

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

The static keyword in C# is used to declare class members that belong to the class itself rather than to any specific instance. When a member is declared as static, it means there is only one copy of that member shared across all instances of the class. Static members can be accessed directly using the class name without creating an object instance. They are commonly used for utility methods, constants, and shared data that should be consistent across all instances of a class. Syntax Following is the syntax for declaring static members − public static ...

Read More

How to compare two Dates in C#?

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

To compare dates in C#, you need to first set two dates to be compared using the DateTime object. The DateTime class in C# provides several methods and operators for date comparison including direct comparison operators, the CompareTo() method, and specialized methods like Equals(). Syntax Following are the different syntaxes for comparing dates − // Using comparison operators if (date1 < date2) { } if (date1 > date2) { } if (date1 == date2) { } // Using CompareTo method int result = date1.CompareTo(date2); // Using Equals method bool isEqual = date1.Equals(date2); ...

Read More
Showing 11331–11340 of 61,297 articles
Advertisements