Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 700057
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T03:27:18+00:00 2026-05-14T03:27:18+00:00

I have a class Similar to this public class Model { public TimeSpan Time1

  • 0

I have a class Similar to this

 public class Model
{
    public TimeSpan Time1 {get; set;}
    public TimeSpan Time2 { get; set; }
    public TimeSpan Time3 { get; set; }
    public TimeSpan Time4 { get; set; }

}

Now Let’s Imagine I have to populate the times during runtime and then Figure out the time remaining between Time 1 and Time 2, then when that passes Find the time remaining between Time2 and Time3 and so on. However, I need to take into account what the time is right now.

For Example:

Now it is 1:00 PM

Time1=5:00 AM
Time 2 = 12:00 PM
Time 3= 4:00 PM
Time 4 = 6:00 PM

So since the time is 1:00PM, I need to find the difference between Time 2 and Time 3

Now is there a smarter way other than reflection to determine this? Should i add something in my class

  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T03:27:18+00:00Added an answer on May 14, 2026 at 3:27 am

    If you need to keep the existing structure of your class, you could add a method to enumerate through the times:

    public class Model
    {
        public TimeSpan Time1 {get; set;}
        public TimeSpan Time2 { get; set; }
        public TimeSpan Time3 { get; set; }
        public TimeSpan Time4 { get; set; }
    
        public IEnumerable<TimeSpan> GetTimes()
        {
            yield return Time1;
            yield return Time2;
            yield return Time3;
            yield return Time4;
        }
    }
    

    And use it like this:

    foreach (TimeSpan time in model.GetTimes())
    {
        // use the TimeSpan
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a model similar to this: public class myModel { public ClassA ObjectA
I have something similar to this model: public class Product { public int ID
I have this model : public class Person { public string Name { get;
I have an MVC project similar to this... Model Public Class ItemDetails Public Property
I have a model similar to this: public class SampleModel { public Product Product
I have a constructor method similar to this: public class Foo { public Foo
I have documents similar to this in RavenDB: public class MyClass { ... public
I have a structure similar to this: class OuterClass{ AnimatorListener sth; public OuterClass(){ sth
I have a similar code snippet like this class Search { public function search($for,
I have a model like this public class Local { public int Id {

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.