- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Decimal.Remainder() Method in C#
The Decimal.Remainder() method in C# is used to calculate the remainder after dividing two Decimal values.
Syntax
Following is the syntax −
public static decimal Remainder (decimal val1, decimal val2);
Above, val1 is the dividend, whereas val2 is the divisor.
Example
Let us now see an example to implement the Decimal.Remainder() method −
using System; public class Demo { public static void Main(){ Decimal val1 = 45.15m; Decimal val2 = 15.15m; Console.WriteLine("Decimal 1 = "+val1); Console.WriteLine("Decimal 2 = "+val2); Console.WriteLine("After Division = "+(Decimal.Divide(val1,val2))); Console.WriteLine("Remainder = "+(Decimal.Remainder(val1,val2))); } }
Output
This will produce the following output −
Decimal 1 = 45.15 Decimal 2 = 15.15 After Division = 2.9801980198019801980198019802 Remainder = 14.85
Example
Let us now see another example to implement the Decimal.Remainder() method −
using System; public class Demo { public static void Main(){ Decimal val1 = 1.00m; Decimal val2 = 1.00m; Console.WriteLine("Decimal 1 = "+val1); Console.WriteLine("Decimal 2 = "+val2); Console.WriteLine("After Division = "+(Decimal.Divide(val1,val2))); Console.WriteLine("Remainder = "+(Decimal.Remainder(val1,val2))); } }
Output
This will produce the following output −
Decimal 1 = 1.00 Decimal 2 = 1.00 After Division = 1 Remainder = 0.00
Advertisements
To Continue Learning Please Login
Login with Google