- Trending Categories
- 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 constants in C#
Decimal type has constants to get the minimum and maximum values.
Set a decimal value −
decimal d = 5.8M;
To get the minimum and maximum values of the decimal type, use the following properties −
decimal.MaxValue decimal.MinValue
Here is the complete code −
Example
using System; using System.Linq; class Demo { static void Main() { decimal d = 5.8M; Console.WriteLine(d); Console.WriteLine("Maximum Value: "+decimal.MaxValue); Console.WriteLine("Maximum Value: "+decimal.MinValue); } }
Output
5.8 Maximum Value: 79228162514264337593543950335 Maximum Value: -79228162514264337593543950335
Advertisements