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 191 of 196
DateTimeOffset.ToUnixTimeSeconds() Method in C#
The DateTimeOffset.ToUnixTimeSeconds() method in C# returns the number of seconds that have elapsed since the Unix epoch (1970-01-01T00:00:00Z). This method is particularly useful when working with Unix timestamps or when interfacing with systems that use Unix time. Syntax Following is the syntax − public long ToUnixTimeSeconds(); Return Value The method returns a long value representing the number of seconds since the Unix epoch. If the DateTimeOffset represents a time before the epoch, the return value will be negative. Unix Time Calculation Unix Epoch ...
Read MoreDecimal.Add() Method in C#
The Decimal.Add() method in C# is a static method that adds two specified decimal values and returns their sum. This method provides precise decimal arithmetic, which is essential for financial calculations where floating-point errors must be avoided. Syntax Following is the syntax − public static decimal Add(decimal val1, decimal val2); Parameters val1 − The first decimal value to add. val2 − The second decimal value to add. Return Value Returns a decimal value that represents the sum of val1 and val2. Using Decimal.Add() with Regular Values Example ...
Read MoreDecimal.Ceiling() Method in C#
The Decimal.Ceiling() method in C# returns the smallest integral value that is greater than or equal to the specified decimal number. This method rounds up to the nearest whole number, regardless of whether the decimal portion is less than or greater than 0.5. Syntax Following is the syntax − public static decimal Ceiling(decimal val); Parameters val − A decimal number that needs to be rounded up to the nearest integer. Return Value Returns a decimal value representing the smallest integer greater than or equal to the input value. ...
Read MoreDecimal.ToByte() Method in C#
The Decimal.ToByte() method in C# converts a decimal value to its equivalent 8-bit unsigned integer (byte). This method truncates the decimal portion and returns only the integer part. The byte data type can store values from 0 to 255. Syntax Following is the syntax − public static byte ToByte(decimal val); Parameters val − The decimal number to convert to a byte value. Return Value Returns a byte value that represents the truncated integer portion of the specified decimal. If the decimal is negative, it rounds toward zero. How ...
Read MoreChar.Equals() Method in C#
The Char.Equals() method in C# is used to compare two character values for equality. It returns true if the character instance is equal to the specified character value, and false otherwise. This method is case-sensitive and performs an exact character comparison. Syntax Following is the syntax for the Char.Equals() method − public bool Equals(char value); public override bool Equals(object obj); Parameters value − A character to compare with the current character instance. obj − An object to compare with the current character instance. Return Value ...
Read MoreChar.GetNumericValue() Method in C#
The Char.GetNumericValue() method in C# converts a specified Unicode character to its corresponding numeric value as a double. This method is particularly useful when working with Unicode digits from various scripts and numeral systems. Syntax Following is the syntax for the Char.GetNumericValue() method − public static double GetNumericValue(char ch); Parameters ch − A Unicode character to convert to its numeric value. Return Value The method returns a double representing the numeric value of the character. If the character does not represent a numeric digit, it returns -1. ...
Read MoreChar.GetUnicodeCategory(String, Int32) Method with Examples in C#
The Char.GetUnicodeCategory(String, Int32) method in C# categorizes the character at the specified position in a specified string into a group identified by one of the UnicodeCategory values. This method is useful for determining the type of character (letter, digit, punctuation, etc.) at a specific index within a string. Syntax Following is the syntax − public static System.Globalization.UnicodeCategory GetUnicodeCategory(string str, int index); Parameters str − The string to examine. index − The zero-based position of the character to categorize within the string. Return Value Returns a UnicodeCategory enumeration value that ...
Read MoreInt16.CompareTo() Method in C#
The Int16.CompareTo() method in C# is used to compare a 16-bit signed integer (short) with another value and returns an integer that indicates their relative order. This method is essential for sorting operations and determining the relationship between two Int16 values. Syntax The Int16.CompareTo() method has two overloads − public int CompareTo(short value); public int CompareTo(object value); Parameters value − A 16-bit signed integer or an object to compare with the current instance. Return Value The method returns an integer with the following meaning − ...
Read MoreDecimal.ToDouble() Method in C#
The Decimal.ToDouble() method in C# is used to convert the value of the specified Decimal to the equivalent double-precision floating-point number. This conversion is useful when you need to perform operations that require double precision or when interfacing with APIs that expect double values. Syntax Following is the syntax − public static double ToDouble(decimal val); Parameters val − The decimal number to convert to a double-precision floating-point number. Return Value A double-precision floating-point number that is equivalent to the specified decimal value. Using Decimal.ToDouble() with Small Values Let us ...
Read MoreDecimal.ToInt16() Method in C#
The Decimal.ToInt16() method in C# is used to convert the value of the specified Decimal to the equivalent 16-bit signed integer (short). This method performs truncation, discarding any fractional part of the decimal number. Syntax Following is the syntax − public static short ToInt16(decimal val); Parameters val − The decimal number to convert. Return Value Returns a 16-bit signed integer (short) that is equivalent to the decimal value after truncation. The range of short is -32, 768 to 32, 767. Using Decimal.ToInt16() with Positive and Negative Values The method ...
Read More