![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
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.Divide() Method in C#
The Decimal.Divide() method in C# is used to divide two specified Decimal values.
Syntax
Following is the syntax −
public static decimal Divide (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.Divide() method −
using System; public class Demo { public static void Main(){ Decimal val1 = 65.15m; Decimal val2 = 5.15m; Console.WriteLine("Decimal 1 = "+val1); Console.WriteLine("Decimal 2 = "+val2); Console.WriteLine("After Division = "+(Decimal.Divide(val1,val2))); } }
Output
This will produce the following output −
Decimal 1 = 65.15 Decimal 2 = 5.15 After Division = 12.650485436893203883495145631
Example
Let us now see another example to implement the Decimal.Divide() method −
using System; public class Demo { public static void Main(){ Decimal val1 = 1.0m; Decimal val2 = 1.0m; Console.WriteLine("Decimal 1 = "+val1); Console.WriteLine("Decimal 2 = "+val2); Console.WriteLine("After Division = "+(Decimal.Divide(val1,val2))); } }
Output
This will produce the following output −
Decimal 1 = 1.0 Decimal 2 = 1.0 After Division = 1
Advertisements