private void btnPost_Click(object sender, EventArgs e) { string msg = tm.PostTweet(txtTweet.Text); lblStatus.Text = msg; refreshTweets(); }
static void Main(string[] args) { string choice; tweetManagerFile tm = new tweetManagerFile(); do { Console.WriteLine("----Main Menu----"); Console.WriteLine(); Console.WriteLine("1. View All Tweets."); Console.WriteLine("2. Post new Post."); Console.WriteLine("3. Search"); Console.WriteLine("4. Exit."); choice = Console.ReadLine(); if (choice == "1") { for (int i = 0; i < tm.TweetCounter(); i++) { Console.WriteLine("Tweet #{0}:{1}", i + 1, tm.GetTweets()[i]); } } if (choice == "2") { Console.Write("Enter your tweet: "); string tweet = Console.ReadLine(); string msg = tm.PostTweet(tweet); Console.WriteLine(msg); } if (choice == "3") { Console.Write("Enter search term: "); string search = Console.ReadLine(); List <string> results = tm.Search(search); Console.WriteLine("Found " + results.Count + " tweets. "); } Console.WriteLine("You entered {0}", choice); }while (choice != "4"); Console.ReadLine(); /* * string[] tweets = new string[4]; * * for (int i = 0; i < tweets.Length; i++) * { * Console.WriteLine("Enter tweet #{0}: ", i + 1); * tweets[i] = Console.ReadLine(); * * } * * * * Console.WriteLine("Tweet posted successfully."); * Console.WriteLine(); * * Console.Write("Your tweets: "); * for (int i = 0; i < tweets.Length; i++) * { * if (tweets[i].Length > 140) * Console.WriteLine("Tweet is longer than 140 chars"); * else * Console.WriteLine("Your tweet #{0} is '{1}': ",i +1, tweets[i] ); * } * * Console.ReadLine();*/ }