As is stated, I will post programs I have written for C# here, as I progress through the tutorials. These are for my benefit, but they might aid as an example or clarification for certain topics.
I recommend everyone does test programs as they progress through the tutorials on this site. This will help you build logistical thinking and reinforce this material in your head. Just following along will not turn you into a polished programmer. You'll need to a lot of problem solving on your own. So, I suggest, you start now!
Here is a simple program I did to go over a few things I learned after I got through the 'Looping' section.
Note: I left the generic structure intact because I don't feel like realigning everything.
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Loops_Input_Math_Practice { class Program { static void Main(string[] args) { // Some variables to store information about the user. int age; int favoriteNumber; string firstName; string lastName; Console.Write("How old are you: "); // Display message asking for age. string ageAsText = Console.ReadLine(); // Store age as a string age = Convert.ToInt32(ageAsText); // convert it to an integer Console.Write("What is your favorite number: "); string favoriteNumberAsText = Console.ReadLine(); favoriteNumber = Convert.ToInt32(favoriteNumberAsText); Console.Write("What is your first name: "); firstName = Console.ReadLine(); // Don't need to convert since we are dealing with a string Console.Write("What is your last name: "); lastName = Console.ReadLine(); // The loops are pointless but I can't think of good examples. int counter = 0; do { if (counter == 0) // If counter is at 0, display user's age. { Console.WriteLine("Your are " + age + " years old."); } else // Else display double the user's age. { Console.WriteLine("Twice your age is " + age * 2 + " years old."); break; // Get out of the forever loop we made. } counter++; // Update counter so we can exit the loop during the next iteration or we will be stuck here forever. } while (true); // Won't exit till it runs into something like a break statement. // This loop would of been more clear if written as a for loop, but this is for demonstration purposes. int number = 0; // Value we will be updating and checking in the loop while (number <= 10) // Will use the values 0 - 10 { // Shows the multiplication chart for the user's favorite number from 0 - 10 // Example: 7 x 0 = 0, 7 x 1 = 7, etc.! Console.WriteLine(favoriteNumber + " x " + number + " = " + favoriteNumber * number); number++; // Update the value so we can eventually exit our loop } Console.Write("Give me a number from 1 - 10: "); string aNumberAsText = Console.ReadLine(); int aNumber = Convert.ToInt32(aNumberAsText); for (int count = 0; count < aNumber; count++) { for (int first = 0; first < 1; first++) { Console.Write(firstName); Console.Write(" "); // Note: You could just add Console.Write(lastName); here and forget the for loop below. Was just to show a 3 tiered(nested) loop. for (int last = 0; last < 1; last++) { Console.Write(lastName); } } Console.WriteLine(); } Console.ReadKey(); } } }