title: c# - Object reference not set to an instance
body: <p>I'm trying to get tweets from twitter</p>
  <p>But I get an error</p>
  <blockquote>
  <p>Object reference not set to an instance</p>
  </blockquote>
  <p>Code:</p>
  <pre><code>    public void Call_Tweet_Update()
      {
          var service = new TwitterService(Consumer_Key, Consumer_Secret);
          service.AuthenticateWith(Access_Token, AccessToken_Secret);
  
          var tweets = service.ListTweetsOnHomeTimeline(new ListTweetsOnHomeTimelineOptions { Count = 200 });
          string[] twt_id = new string[50];
          long id = 0;
          int i = 0;
          int increment = 0;
          string twtid;
          string screenname;
  
          foreach (var tweet in tweets)
          {
              if (tweet.InReplyToStatusId.ToString() != &quot;&quot;)
              {
                  if ((tweet.User.ScreenName == &quot;IIPL_LTD&quot;) || (tweet.Text.StartsWith(&quot;@IIPL_LTD&quot;)))
                  {
                      string replyid = tweet.InReplyToStatusId.ToString();
  
                      while (replyid != &quot;&quot;)
                      {
                          if (i == 0)
                          {
                              twt_id[i] = tweet.Id.ToString();
                          }
                          id = Convert.ToInt64(replyid);
                          var twt = service.GetTweet(new GetTweetOptions { Id = id });
                          //twtid = Convert.ToInt64(tweet.Id).ToString();
                          twtid = Convert.ToInt64(twt.Id).ToString();
                          //abc = twtid;
                          i = i + 1;
                          twt_id[i] = twtid;
                          replyid = twt.InReplyToStatusId.ToString();
                         // replyid = tweet.InReplyToStatusId.ToString();
                          // replyid = &quot;&quot;;
                          increment = increment + 1;
                      }
                    }
                  }
  </code></pre>
  <p>this is what the code terminated by Object reference not set to an instance</p>
  <blockquote>
  <p>Getting id as 38811592704 but the below line getting null value</p>
  <p>var twt = service.GetTweet(new GetTweetOptions { Id = id });</p>
  </blockquote>
  <pre><code>   while (replyid != &quot;&quot;)
     {
         if (i == 0)
         {
            twt_id[i] = tweet.Id.ToString();
         }
         id = Convert.ToInt64(replyid);
         var twt = service.GetTweet(new GetTweetOptions { Id = id });
         twtid = Convert.ToInt64(twt.Id).ToString();
      }
  </code></pre>
  <p>Any ideas? Thanks in advance.</p>