Csharp Articles

Page 178 of 196

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

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

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

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 210 Views

The Convert.ToSByte(String, IFormatProvider) method in C# converts the specified string representation of a number to an equivalent 8-bit signed integer, using the specified culture-specific formatting information. This method is particularly useful when working with numeric strings that may have different formatting conventions based on locale. Syntax Following is the syntax − public static sbyte ToSByte(string value, IFormatProvider provider); Parameters value − A string that contains the number to convert. The value must be between -128 and 127. provider − An object that supplies culture-specific formatting information. This can be ...

Read More

Dictionary Class in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 993 Views

Dictionary in C# is a generic collection class that stores key-value pairs. It belongs to the System.Collections.Generic namespace and provides fast lookups based on keys. Each key in the dictionary must be unique, but values can be duplicated. Syntax Following is the syntax for declaring a Dictionary − public class Dictionary Where TKey is the type of keys and TValue is the type of values in the dictionary. To create and initialize a Dictionary − Dictionary dict = new Dictionary(); dict.Add(key, value); dict[key] = value; // Alternative way to add/update ...

Read More

Dictionary.Values Property in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 367 Views

The Dictionary.Values property in C# is used to retrieve all the values stored in a Dictionary. This property returns a ValueCollection that contains all values from the dictionary, preserving the order in which they were added. Syntax Following is the syntax for the Dictionary.Values property − public Dictionary.ValueCollection Values { get; } Return Value The property returns a Dictionary.ValueCollection containing all the values in the dictionary. This collection is a live view of the dictionary values, meaning changes to the dictionary are reflected in the collection. Dictionary.Values Property ...

Read More

DateTimeOffset.AddYears() Method in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 108 Views

The DateTimeOffset.AddYears() method in C# is used to add a specified number of years to a DateTimeOffset instance. This method returns a new DateTimeOffset object representing the date and time with the added years, while preserving the original offset from UTC. Syntax Following is the syntax for the DateTimeOffset.AddYears() method − public DateTimeOffset AddYears(int years); Parameters The method takes one parameter − years − An integer representing the number of years to add. Use positive values to add years, negative values to subtract years. Return Value ...

Read More

DateTimeOffset.Compare() Method in C#

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

The DateTimeOffset.Compare() method in C# is used to compare two DateTimeOffset objects and indicates whether the first is earlier than the second, equal to the second, or later than the second. It returns an integer value that represents the relationship between the two dates. 0 − If val1 is later than val2 DateTimeOffset.Compare() Return Values < 0 val1 is earlier than val2 0 val1 equals val2 > 0 ...

Read More

How to create 3-Tuple or Triple Tuple in C#?

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 499 Views

The Tuple class represents a 3-tuple, also called a triple. A tuple is a data structure that contains a sequence of elements of different types, providing a convenient way to group related data together without creating a custom class. 3-tuples are commonly used for − Easier access to a data set with three related values. Easier manipulation of grouped data. To represent a single set of three related values. To return multiple values from a method. To pass multiple values to a method as a single parameter. ...

Read More

How to create 4-Tuple or quadruple in C#?

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 290 Views

The Tuple class represents a 4-tuple, which is called a quadruple. A tuple is a data structure that holds a sequence of elements of different types in a single object. 4-tuples are commonly used for − Easier access to a data set. Easier manipulation of a data set. To represent a single set of data. To return multiple values from a method. To pass multiple values to a method. 4-Tuple Structure Item1 Item2 Item3 ...

Read More

Math.Max() Method in C#

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

The Math.Max() method in C# returns the larger of two specified numbers. This static method is overloaded to work with various numeric types including int, double, decimal, float, and more. Syntax The Math.Max() method has multiple overloads for different numeric types − public static int Max(int val1, int val2); public static double Max(double val1, double val2); public static decimal Max(decimal val1, decimal val2); public static float Max(float val1, float val2); public static long Max(long val1, long val2); public static byte Max(byte val1, byte val2); public static short Max(short val1, short val2); public static uint Max(uint val1, ...

Read More
Showing 1771–1780 of 1,951 articles
« Prev 1 176 177 178 179 180 196 Next »
Advertisements