Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Csharp Articles
Page 178 of 196
DateTime.AddHours() Method in C#
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 MoreConvert.ToDouble(String, IFormatProvider) Method in C#
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 MoreConvert.ToSByte(String, IFormatProvider) Method in C#
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 MoreDictionary Class in C#
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 MoreDictionary.Values Property in C#
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 MoreDateTimeOffset.AddYears() Method in C#
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 MoreDateTimeOffset.Compare() Method in C#
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 MoreHow to create 3-Tuple or Triple Tuple in C#?
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 MoreHow to create 4-Tuple or quadruple in C#?
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 MoreMath.Max() Method in C#
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