Decimal.Add() Method in C# Last Updated : 29 Jan, 2019 Comments Improve Suggest changes Like Article Like Report This method is used to add two specified decimal values. Syntax: public static decimal Add (decimal a1, decimal a2); Parameters: a1: This parameter specifies the first value to add. a2: This parameter specifies the second value to add. Return Value: Decimal sum of a1 & a2. Exceptions: This method will give OverflowException if the sum of a1 and a2 is less than smallest possible value of Decimal or greater than the largest possible value of Decimal. Below programs illustrate the use of Decimal.Add(Decimal, Decimal) Method Example 1: csharp // C# program to demonstrate the // Decimal.Add(Decimal, Decimal) // Method using System; using System.Globalization; class GFG { // Main Method public static void Main() { try { // Declaring the decimal // variables Decimal a1 = .01m; Decimal a2 = .03m; // adding the two Decimal value // using Add() method; Decimal value = Decimal.Add(a1, a2); // Display the sum Console.WriteLine("Decimal Sum : {0}", value); } catch (OverflowException e) { Console.Write("Exception Thrown: "); Console.Write("{0}", e.GetType(), e.Message); } } } Output: Decimal Sum : 0.04 Example 2: For OverflowException csharp // C# program to demonstrate the // Decimal.Add(Decimal, Decimal) // Method using System; using System.Globalization; class GFG { // Main Method public static void Main() { try { // Declaring the decimal variables Decimal a1 = 1.01m; Decimal a2 = Decimal.MaxValue; // adding the two Decimal value // using Add() method; Decimal value = Decimal.Add(a1, a2); // Display the sum Console.WriteLine("Decimal Sum : {0}", value); } catch (OverflowException e) { Console.Write("Exception Thrown: "); Console.Write("{0}", e.GetType(), e.Message); } } } Output: Exception Thrown: System.OverflowException Comment More infoAdvertise with us Next Article Decimal.Add() Method in C# I IshwarGupta Follow Improve Article Tags : C# CSharp-method CSharp-Decimal-Struct Similar Reads DateTime.Add() Method in C# This method is used to return a new DateTime that adds the value of the specified TimeSpan to the value of this instance. Syntax: public DateTime Add (TimeSpan value); Here, value is a positive or negative time interval. Return Value: This method returns an object whose value is the sum of the date 2 min read DateTime.AddDays() Method in C# This method is used to return a new DateTime that adds the specified number of days to the value of this instance. Syntax: public DateTime AddDays (double value); Here, the value is the number of whole and fractional days. The value parameter can be negative or positive. Return Value: This method re 2 min read DateTime.AddYears() Method in C# This method is used to returns a new DateTime that adds the specified number of years to the value of this instance. Syntax: public DateTime AddYears (int value); Here, the value is the number of years. The value parameter can be negative or positive. Return Value: This method returns an object whos 3 min read DateTime.AddHours() Method in C# This method is used to return a new DateTime that adds the specified number of hours to the value of this instance. Syntax: public DateTime AddHours (double value); Here, the value is the number of whole and fractional hours. The value parameter can be negative or positive. Return Value: This method 3 min read DateTime.AddTicks() Method in C# This method is used to returns a new DateTime that adds the specified number of ticks to the value of this instance. This method does not change the value of this DateTime. Instead, it returns a new DateTime whose value is the result of this operation. Syntax: public DateTime AddTicks (long value); 2 min read DateTimeOffset.Add() Method in C# This method is used to return a new DateTimeOffset object that adds a specified time interval to the value of this instance. Syntax: public DateTimeOffset Add (TimeSpan timeSpan); Here, it takes a TimeSpan object that represents a positive or a negative time interval.Return Value: This method return 2 min read DateTime.AddMonths() Method in C# This method is used to return a new DateTime that adds the specified number of months to the value of this instance. Syntax: public DateTime AddMonths (int months); Here, months is the number of months. The months parameter can be negative or positive. Return Value: This method returns an object who 2 min read DateTime.AddSeconds() Method in C# This method is used to return a new DateTime that adds the specified number of seconds to the value of this instance. Syntax: public DateTime AddSeconds (double value); Here, value is a number of whole and fractional seconds. The value parameter can be negative or positive. Return Value: This method 2 min read C# | Dictionary.Add() Method Dictionary<TKey,TValue>.Add() Method is used to add a specified key and value to the dictionary. Syntax: public void Add (TKey key, TValue value); Parameters: key: It is the key of the element to add. value: It is the value of the element to add. The value can be null for reference types. Exce 3 min read DateTime.AddMinutes() Method in C# This method is used to return a new DateTime that adds the specified number of minutes to the value of this instance. Syntax: public DateTime AddMinutes (double value); Here, value is a number of whole and fractional minutes. The value parameter can be negative or positive. Return Value: This method 2 min read Like