
- C# Basic Tutorial
- C# - Home
- C# - Overview
- C# - Environment
- C# - Program Structure
- C# - Basic Syntax
- C# - Data Types
- C# - Type Conversion
- C# - Variables
- C# - Constants
- C# - Operators
- C# - Decision Making
- C# - Loops
- C# - Encapsulation
- C# - Methods
- C# - Nullables
- C# - Arrays
- C# - Strings
- C# - Structure
- C# - Enums
- C# - Classes
- C# - Inheritance
- C# - Polymorphism
- C# - Operator Overloading
- C# - Interfaces
- C# - Namespaces
- C# - Preprocessor Directives
- C# - Regular Expressions
- C# - Exception Handling
- C# - File I/O
- C# Advanced Tutorial
- C# - Attributes
- C# - Reflection
- C# - Properties
- C# - Indexers
- C# - Delegates
- C# - Events
- C# - Collections
- C# - Generics
- C# - Anonymous Methods
- C# - Unsafe Codes
- C# - Multithreading
- C# Useful Resources
- C# - Questions and Answers
- C# - Quick Guide
- C# - Useful Resources
- C# - Discussion
C# Program to Add Two TimeSpan
Firstly, set two TimeSpans −
TimeSpan t1 = TimeSpan.FromMinutes(1); TimeSpan t2 = TimeSpan.FromMinutes(2);
To add it, use the Add() method −
TimeSpan res = t1.Add(t2);
Example
Using System; using System.Linq; public class Demo { public static void Main() { TimeSpan t1 = TimeSpan.FromMinutes(1); TimeSpan t2 = TimeSpan.FromMinutes(2); Console.WriteLine("First TimeSpan: "+t1); Console.WriteLine("Second TimeSpan: "+t2); // Adding TimeSpan res = t1.Add(t2); Console.WriteLine("Resultant TimeSpan: "+res); } }
- Related Articles
- C# Program to Subtract Two TimeSpan
- C# program to add two matrices
- C++ Program to Add Two Numbers
- C Program to add two fractions
- C Program to Add two Integers
- C# TimeSpan Min value
- C# TimeSpan Max value
- Format TimeSpan in C#
- Program to add two binary strings in C++
- Program to Add Two Complex Numbers in C
- C++ program to overload addition operator to add two matrices
- C++ Program to Add Two Matrix Using Multi-dimensional Arrays
- Write a program to add two complex numbers using C
- C++ program to overload addition operator to add two complex numbers
- Add two numbers represented by two arrays in C Program

Advertisements