Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
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);
}
}Advertisements