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 7557603
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T12:10:30+00:00 2026-05-30T12:10:30+00:00

I have got code something like IEnumerable<TwitterStatus> mentions = service.ListTweetsOnHomeTimeline(); RecentTweetList.ItemsSource = mentions; What

  • 0

I have got code something like

IEnumerable<TwitterStatus> mentions = service.ListTweetsOnHomeTimeline();
RecentTweetList.ItemsSource = mentions;

What I want to do is to add somehow to TwitterStatus 1 extra attribute to convert CreatedDate of that class to get minutes. (I cannot redesign TwitterStatus.)

So I guessed to do like:

public class NewTwitterStatus : TwitterStatus
{
        public string MinAgo 
        {
            get 
            {
                TimeSpan diff = DateTime.Now.Subtract(base.CreatedDate);
                return diff.Minutes.ToString() + "m";
            }
        }
}

But I cannot figure out how to do the cast?

IEnumerable<NewTwitterStatus > mentions = (????)service.ListTweetsOnHomeTimeline();

Thank you all of you guys!

THE SOLUTION (based on Chris’ suggestion):

IEnumerable<NewTwitterStatus> mentions = service.ListTweetsOnHomeTimeline().Select(x => new NewTwitterStatus(x));
RecentTweetList.ItemsSource = mentions;



 public class NewTwitterStatus
    {
        TwitterStatus Data { set; get; }

        public NewTwitterStatus(TwitterStatus ts)
        {
            Data = ts;
            ts = null;
        }

        public string ProfileImageUrl
        {
            get
            {
                return Data.User.ProfileImageUrl;
            }
        }


        public string ScreenName
        {
            get
            {
                return Data.User.ScreenName;
            }
        }

        public string UserName
        {
            get
            {
                return Data.User.Name;
            }
        }

        public string Text
        {
            get
            {                
                return Data.Text;
            }
        }

        public string MinAgo 
        {
            get 
            {
                TimeSpan diff = DateTime.Now.Subtract(Data.CreatedDate);
                int mins = diff.Minutes * -1;

                if (mins < 60)
                    return mins.ToString() + "m";
                else  
                {
                    double h = mins / 60;
                    double m = mins % 60;
                    return h.ToString()  + "h " + m.ToString() + "m";
                }


            }
        }
  • 1 1 Answer
  • 0 Views
  • 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-30T12:10:31+00:00Added an answer on May 30, 2026 at 12:10 pm

    If you can’t do an extension method then I would make your NewTwitterStatus class have a constructor that takes a TwitterStatus to allow easy conversion and then use some linq like the following:

    IEnumerable<NewTwitterStatus > mentions = 
        service.ListTweetsOnHomeTimeline().Select(x=> new NewTwitterStatus(x));
    

    This will basically take the original IEnumberable and map the elements into the new type. Its a bit less elegant than an extension method but should do the trick.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have got my code something like below which repeats to the number of
I have got code like this var challegneListener; $(document).ready(function(){ var challegneListener = setInterval(challengeListenerBot(),5000); });
I have got some javascript code and I'd like to convert this to C#.
I have got a chunk of code like for i in range(0, len(a)) b[i]
I have a piece of code something like below. I'm using Microsoft Visual C#
i have a <select> tag i want redirect user onchange i got an code
I have got a link with the click event in my JQuery, something like
I've got some code which involves iterating through a std::hash_set something like this: typedef
Lets say that I have got a vector like this. std::vector<a_complicated_whatever_identifier *> *something =
I have a code segment something like this: def test() : Seq[Int] = List(A,

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.