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 187 of 196
DateTime.AddMonths() Method in C#
The DateTime.AddMonths() method in C# is used to add the specified number of months to the value of a DateTime instance. This method returns a new DateTime object representing the date after adding the specified months, while the original DateTime remains unchanged. Syntax Following is the syntax for the DateTime.AddMonths() method − public DateTime AddMonths(int months); Parameters months − An integer representing the number of months to add. Use positive values to add months and negative values to subtract months. The value can range from -120, 000 to 120, 000. Return Value ...
Read MoreDateTime.AddSeconds() Method in C#
The DateTime.AddSeconds() method in C# is used to add the specified number of seconds to the value of this instance. This returns a new DateTime object without modifying the original DateTime instance. Syntax Following is the syntax − public DateTime AddSeconds(double sec); Parameters sec − A double value representing the number of seconds to be added. If you want to subtract seconds, then set a negative value. The value can include fractional seconds. Return Value This method returns a new DateTime object that represents the date and time after adding the ...
Read MoreDateTime.AddTicks() Method in C#
The DateTime.AddTicks() method in C# is used to add a specified number of ticks to the value of this instance. It returns a new DateTime representing the adjusted time. A tick represents 100 nanoseconds, making this method useful for precise time calculations. Syntax Following is the syntax − public DateTime AddTicks(long ticks); Parameters ticks: A long value representing the number of ticks to add. Each tick equals 100 nanoseconds. Positive values add time, while negative values subtract time. Return Value Returns a new DateTime object whose value is the sum of ...
Read MoreInt16.GetTypeCode Method in C# with Examples
The Int16.GetTypeCode() method in C# is used to return the TypeCode for value type Int16. This method is part of the IConvertible interface and helps identify the underlying data type at runtime. The TypeCode enumeration provides a way to categorize the data types supported by the Common Language Runtime (CLR). For Int16 values, this method always returns TypeCode.Int16. Syntax Following is the syntax − public TypeCode GetTypeCode(); Return Value This method returns TypeCode.Int16, which is the enumerated constant representing the Int16 type. Using GetTypeCode() with Int16 Values Example Let ...
Read MoreInt32.CompareTo Method in C# with Examples
The Int32.CompareTo method in C# is used to compare the current integer instance with another integer or object and returns an indication of their relative values. This method is particularly useful for sorting operations and conditional comparisons. Syntax The Int32.CompareTo method has two overloads − public int CompareTo(int value); public int CompareTo(object value); Parameters value − An integer or object to compare with the current instance. Return Value Return Value Condition Meaning Less than zero (< 0) Current instance < ...
Read MoreDecimal.FromOACurrency() Method in C#
The Decimal.FromOACurrency() method in C# converts a 64-bit signed integer containing an OLE Automation Currency value to its equivalent decimal representation. OLE Automation Currency stores currency values as scaled integers, where the value is multiplied by 10, 000 to preserve four decimal places of precision. Syntax Following is the syntax for the Decimal.FromOACurrency() method − public static decimal FromOACurrency(long val); Parameters val: A 64-bit signed integer that contains an OLE Automation Currency value to be converted. Return Value Returns a decimal value equivalent to the OLE Automation Currency value. The returned ...
Read MoreType.GetNestedType() Method in C#
The Type.GetNestedType() method in C# is used to retrieve a specific nested type that is declared within the current type. This method is part of the System.Reflection namespace and provides access to nested classes, interfaces, structs, or other types defined inside a parent type. Syntax Following are the overloads for the GetNestedType() method − public Type GetNestedType(string name); public abstract Type GetNestedType(string name, System.Reflection.BindingFlags bindingAttr); Parameters name − The string containing the simple name of the nested type to get. bindingAttr − A combination of enumeration values that specify how the search ...
Read MoreType.GetNestedTypes() Method in C#
The Type.GetNestedTypes() method in C# is used to get the types nested within the current Type. This method is particularly useful when working with reflection to discover and work with nested classes, interfaces, or other types defined within a class. Syntax Following is the syntax for the GetNestedTypes() method − public Type[] GetNestedTypes(); public abstract Type[] GetNestedTypes(System.Reflection.BindingFlags bindingAttr); Parameters The overloaded version accepts a BindingFlags parameter that specifies which nested types to return − bindingAttr − A combination of BindingFlags values that control which nested types are returned (e.g., Public, NonPublic, ...
Read MoreDateTimeOffset.Add() Method in C#
The DateTimeOffset.Add() method in C# returns a new DateTimeOffset object that represents the original date and time with a specified time interval added to it. This method is useful for performing date and time arithmetic while preserving the original offset information. Syntax Following is the syntax − public DateTimeOffset Add(TimeSpan timespan); Parameters timespan − A TimeSpan object that represents the time interval to add. This can be positive (to add time) or negative (to subtract time). Return Value Returns a new DateTimeOffset object whose value is the sum of ...
Read MoreDateTimeOffset.AddDays() Method in C#
The DateTimeOffset.AddDays() method in C# returns a new DateTimeOffset object that adds a specified number of whole and fractional days to the value of the current instance. This method allows you to add or subtract days while preserving the original timezone offset information. Syntax Following is the syntax − public DateTimeOffset AddDays(double days); Parameters days − A number of whole and fractional days. The value parameter can be negative or positive. Return Value Returns a new DateTimeOffset object whose value is the sum of the date and time represented ...
Read More