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
Articles by AmitDiwan
Page 221 of 840
Decimal.Round() Method in C#
The Decimal.Round() method in C# is used to round a decimal value to the nearest integer or to a specified number of decimal places. This method provides several overloads to handle different rounding scenarios and precision requirements. Syntax The Decimal.Round() method has four main overloads − public static decimal Round(decimal d); public static decimal Round(decimal d, int decimals); public static decimal Round(decimal d, MidpointRounding mode); public static decimal Round(decimal d, int decimals, MidpointRounding mode); Parameters d − The decimal number to be rounded. decimals − The number of decimal ...
Read MoreTuple Class in C#
The Tuple class in C# represents a data structure that can hold a sequence of elements. The Tuple class specifically represents a 7-tuple, also called a septet. Tuples provide a convenient way to group multiple values together without creating a custom class. 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 Syntax Following is the syntax for creating a 7-tuple − Tuple ...
Read MoreDecimal.Subtract() Method in C#
The Decimal.Subtract() method in C# is used to subtract two specified decimal values and returns the result. This static method provides a way to perform decimal subtraction with high precision, making it ideal for financial and monetary calculations. Syntax Following is the syntax − public static decimal Subtract(decimal val1, decimal val2); Parameters val1 − The minuend (the number from which another number is to be subtracted). val2 − The subtrahend (the number that is to be subtracted). Return Value Returns a decimal value that represents ...
Read MoreType.Equals() Method in C#
The Type.Equals() method in C# determines if the underlying system type of the current Type is the same as the underlying system type of the specified Object or Type. This method is essential for type comparison operations in reflection scenarios. Syntax The Type.Equals() method has two overloads − public virtual bool Equals(Type o); public override bool Equals(object o); Parameters o − The object or Type whose underlying system type is to be compared with the underlying system type of the current Type. Return Value Returns true if ...
Read MoreMath.Ceiling() Method in C#
The Math.Ceiling() method in C# returns the smallest integer value that is greater than or equal to the specified number. This method always rounds up to the next whole number, making it useful for scenarios where you need to ensure a minimum integer value. Syntax The Math.Ceiling() method has two overloads − public static decimal Ceiling(decimal val); public static double Ceiling(double val); Parameters val − The decimal or double number to be rounded up to the nearest integer. Return Value Returns the smallest integer value greater than ...
Read MoreInt64.GetTypeCode Method in C# with Examples
The Int64.GetTypeCode() method in C# is used to return the TypeCode for value type Int64. This method is inherited from the IConvertible interface and returns TypeCode.Int64 for all 64-bit signed integer values. Syntax Following is the syntax − public TypeCode GetTypeCode(); Return Value This method returns TypeCode.Int64, which is the enumerated constant representing the Int64 type. Using GetTypeCode() with Different Values Example Let us see an example to implement the Int64.GetTypeCode() method − using System; public class Demo { public static void Main() { ...
Read MoreType.GetArrayRank() Method in C#
The Type.GetArrayRank() method in C# returns the number of dimensions in an array type. This method is useful when working with multidimensional arrays and you need to determine how many dimensions the array has at runtime. The method works only with array types. If called on a non-array type, it throws an ArgumentException. Syntax Following is the syntax for the GetArrayRank() method − public virtual int GetArrayRank(); Return Value The method returns an int representing the number of dimensions in the array. For example, a single-dimensional array returns 1, a two-dimensional array ...
Read MoreMath.Cos() Method in C#
The Math.Cos() method in C# returns the cosine of a specified angle. The angle must be provided in radians, not degrees. This method is part of the System.Math class and is commonly used in mathematical calculations, graphics programming, and trigonometric operations. Syntax Following is the syntax for the Math.Cos() method − public static double Cos(double val); Parameters val − A double value representing the angle in radians whose cosine is to be calculated. Return Value The method returns a double value representing the cosine of the specified ...
Read MoreMathF.Abs() Method in C# with Examples
The MathF.Abs() method in C# is used to return the absolute value of a float number. The absolute value represents the non-negative value of a number without regard to its sign. For example, the absolute value of both -5.5f and 5.5f is 5.5f. This method is part of the System namespace and is specifically designed for float operations, providing better performance than the generic Math.Abs() method when working with single-precision floating-point numbers. Syntax Following is the syntax for the MathF.Abs() method − public static float Abs(float val); Parameters val − A ...
Read MoreMath.IEEERemainder() Method in C#
The Math.IEEERemainder() method in C# returns the remainder resulting from the division of a specified number by another specified number. Unlike the modulus operator (%), this method follows the IEEE 754 standard for floating-point arithmetic, which can produce different results in certain cases. The IEEE remainder is calculated as dividend - (divisor * Math.Round(dividend / divisor)), where the division result is rounded to the nearest even integer when exactly halfway between two integers. Syntax public static double IEEERemainder(double dividend, double divisor); Parameters dividend − A double-precision floating-point number (the number to be ...
Read More