| |
Display the properties for myTimeSpan |
|
using System;
class MainClass {
public static void Main() {
int hours = 4;
int minutes = 12;
int seconds = 10;
int days = 1;
int milliseconds = 20;
long ticks = 300;
TimeSpan myTimeSpan = new TimeSpan(ticks);
Console.WriteLine("myTimeSpan4 = " + myTimeSpan);
Console.WriteLine("myTimeSpan.Days = " + myTimeSpan.Days);
Console.WriteLine("myTimeSpan.Hours = " + myTimeSpan.Hours);
Console.WriteLine("myTimeSpan.Minutes = " + myTimeSpan.Minutes);
Console.WriteLine("myTimeSpan.Seconds = " + myTimeSpan.Seconds);
Console.WriteLine("myTimeSpan.Milliseconds = " + myTimeSpan.Milliseconds);
Console.WriteLine("myTimeSpan.Ticks = " + myTimeSpan.Ticks);
Console.WriteLine("myTimeSpan.TotalDays = " + myTimeSpan.TotalDays);
Console.WriteLine("myTimeSpan.TotalHours = " + myTimeSpan.TotalHours);
Console.WriteLine("myTimeSpan.TotalMinutes = " +myTimeSpan.TotalMinutes);
Console.WriteLine("myTimeSpan.TotalSeconds = " + myTimeSpan.TotalSeconds);
Console.WriteLine("myTimeSpan.TotalMilliseconds = " + myTimeSpan.TotalMilliseconds);
}
}
|
|
|
Related examples in the same category |
1. | new TimeSpan(2, 12, 0, 0) | | | 2. | TimeSpan.TicksPerDay | | | 3. | Initialize a time span to zero | | | 4. | Initialize a time span to 14 days | | | 5. | Initialize a time span to 1:02:03 | | | 6. | Initialize a time span to 250 milliseconds | | | 7. | Initalize a time span to 99 days, 23 hours, 59 minutes, and 59.9999999 seconds | | | 8. | Calculation based on the TimeSpan | | | 9. | Subtract 15 minutes from the current TimeSpan and print the result | | | 10. | Measuring the Time Taken to Add Some Numbers | | | 11. | Use FromDays(), FromHours(), FromMinutes(), FromSeconds(), FromMilliseconds(), and FromTicks() methods to create new TimeSpan instances | | | 12. | Use the Parse() method to convert strings to TimeSpan instances | | | 13. | Use the Add() method to add a TimeSpan instance to another | | | 14. | Use the Subtract() method to subtract a TimeSpan instance from another | | | 15. | Use the Duration() method to add two TimeSpan instances | | | 16. | Use the Negate() method to add two TimeSpan instances | | | 17. | Use the Parse() method to convert strings to TimeSpan instances | | | 18. | Create a TimeSpan instance, specifying the hours, minutes, and seconds | | | 19. | Create a TimeSpan instance, specifying the days, hours, minutes, and seconds | | | 20. | Create a TimeSpan instance, specifying the days, hours, minutes, seconds, and milliseconds | | | 21. | Create a TimeSpan instance, specifying the number of ticks | | | 22. | Initalize a timespan to 25 milliseconds | | |
|