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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T18:51:47+00:00 2026-06-14T18:51:47+00:00

String status; IEnumerable<TwitterStatus> twitterStatus = twitterService.ListTweetsOnPublicTimeline(); foreach(String status in twitterStatus) { Console.WriteLine(twitterStatus); } Why

  • 0
String status;
            IEnumerable<TwitterStatus> twitterStatus = twitterService.ListTweetsOnPublicTimeline();
            foreach(String status in twitterStatus)
            {
                Console.WriteLine(twitterStatus);
            }

Why it give can not convert string type error in foreach loop ?
this is my whole code

namespace TweetingTest
{
    class Program
    {
        static void Main(string[] args)
        {

            TwitterClientInfo twitterClientInfo = new TwitterClientInfo();
            twitterClientInfo.ConsumerKey = ConsumerKey; //Read ConsumerKey out of the app.config
            twitterClientInfo.ConsumerSecret = ConsumerSecret; //Read the ConsumerSecret out the app.config

            TwitterService twitterService = new TwitterService(twitterClientInfo);

            if (string.IsNullOrEmpty(AccessToken) || string.IsNullOrEmpty(AccessTokenSecret))
            {
                //Now we need the Token and TokenSecret

                //Firstly we need the RequestToken and the AuthorisationUrl
                OAuthRequestToken requestToken = twitterService.GetRequestToken();
                string authUrl = twitterService.GetAuthorizationUri(requestToken).ToString();

                //authUrl is just a URL we can open IE and paste it in if we want
                Console.WriteLine("Please Allow This App to send Tweets on your behalf");
                //Process.Start(authUrl); //Launches a browser that'll go to the AuthUrl.

                //Allow the App
                Console.WriteLine("Enter the PIN from the Browser:");
                string pin = Console.ReadLine();

                OAuthAccessToken accessToken = twitterService.GetAccessToken(requestToken, pin);

                string token = accessToken.Token; //Attach the Debugger and put a break point here
                string tokenSecret = accessToken.TokenSecret; //And another Breakpoint here

                Console.WriteLine("Write Down The AccessToken: " + token);
                Console.WriteLine("Write Down the AccessTokenSecret: " + tokenSecret);
            }

            twitterService.AuthenticateWith(AccessToken, AccessTokenSecret);

            //Console.WriteLine("Enter a Tweet");
            //string tweetMessage;
            //string data;
            //string ListTweetsOnPublicTimeline;
            //string TwitterUserStreamStatus = ListTweetsOnPublicTimeline();
            //TwitterStatus=ListTweetsOnPublicTimeline();
            //tweetMessage = Console.ReadLine();
            //ListTweetsOnPublicTimeline = Console.ReadLine();
            //TwitterStatus twitterStatus = twitterService.SendTweet(tweetMessage);
            //TwitterStatus twitterStatus = twitterService.ListTweetsOnPublicTimeline();
            //String status;
            IEnumerable<TwitterStatus> tweets = twitterService.ListTweetsOnPublicTimeline();
           foreach(var tweet in tweets)
            {
               Console.WriteLine(tweet);
                //Console.WriteLine("{0} says '{1}'", tweet.User.ScreenName, tweet.Text);
            }
            //twitterStatus=Console.ReadLine();
        }

This is my whole code on which I am working and facing just one error on foreach loop which is my lack of knowledge in C#

  • 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-06-14T18:51:49+00:00Added an answer on June 14, 2026 at 6:51 pm

    You will need something like this..

     using TweetSharp;
    
        TwitterService service = new TwitterService();
        IEnumerable<TwitterStatus> tweets = service.ListTweetsOnPublicTimeline();
        foreach (var tweet in tweets)
        {
            Console.WriteLine("{0} says '{1}'", tweet.User.ScreenName, tweet.Text);
        }
    

    Also try this code to see why it is failing.. try to debug response.StatusCode

    using TweetSharp;
    
    TwitterService service = new TwitterService();
    IAsyncResult result = service.ListTweetsOnPublicTimeline(
        (tweets, response) =>
            {
                if(response.StatusCode == HttpStatusCode.OK)
                {
                    foreach (var tweet in tweets)
                    {
                        Console.WriteLine("{0} said '{1}'", tweet.User.ScreenName, tweet.Text);
                    }
                }
            });
    

    More here : https://github.com/danielcrenna/tweetsharp

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

Sidebar

Related Questions

I want to convert from public class Party { public string Type { get;
I have two domain classes. class BillingServiceGroup { Integer billingServiceGroupCode String billingServiceGrpDesc String status
I've got a datatable with two columns Status (string) and Total (integer). Status Total
I have a Supplier Entitiy that contains ID - int Status - string Name
I have a Supplier Entitiy that contains ID - int Status - string Name
Consider a model user: User(id: integer, name: string, email: string, status: string) When I
I am trying to filter result from JSON string based on status selection. I
String sql = update `library`.`memebers` set 'STATUS'=' + 1 +' where mem_id = '+str+';
With signpost 1.2: String authUrl = provider.retrieveRequestToken( consumer, callbackUrl ); Netflix API response: <status>
Dictionary<string,string> items = new Dictionary<string,string>(); IEnumerable<string> textvalues = from c in......//using linQ to query

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.