publicclassProgram { staticvoidMain(string[] args) { stringmessage="Hello World!"; // 07/24/2010 Bob Console.WriteLine(message); // 07/24/2010 Bob message = "I am so proud of this code!"; // 07/24/2010 Bob Console.WriteLine(message); // 07/24/2010 Bob } }
publicclassProgram { staticvoidMain(string[] args) { /* This block of code is no longer needed * because we found out that Y2K was a hoax * and our systems did not roll over to 1/1/1900 */ //DateTime today = DateTime.Today; //if (today == new DateTime(1900, 1, 1)) //{ // today = today.AddYears(100); // string message = "The date has been fixed for Y2K."; // Console.WriteLine(message); //} } }
publicclassProgram { staticvoidMain(string[] args) { /* This is a for loop that prints the * words "I Rule!" to the console screen * 1 million times, each on its own line. It * accomplishes this by starting at 0 and * incrementing by 1. If the value of the * counter equals 1 million the for loop * stops executing.*/ for (inti=0; i < 1000000; i++) { Console.WriteLine("I Rule!"); } } }
publicclassProgram { staticvoidMain(string[] args) { /* I discussed with Jim from Sales over coffee * at the Starbucks on main street one day and he * told me that Sales Reps receive commission * based upon the following structure. * Friday: 25% * Wednesday: 15% * All Other Days: 5% * Did I mention that I ordered the Caramel Latte with * a double shot of Espresso? */ doubleprice=5.00; double commissionRate; double commission; if (DateTime.Today.DayOfWeek == DayOfWeek.Friday) { commissionRate = .25; } elseif (DateTime.Today.DayOfWeek == DayOfWeek.Wednesday) { commissionRate = .15; } else { commissionRate = .05; } commission = price * commissionRate; } }
publicclassProgram { staticvoidMain(string[] args) { //TODO: I need to fix this someday - 07/24/1995 Bob /* I know this error message is hard coded and * I am relying on a Contains function, but * someday I will make this code print a * meaningful error message and exit gracefully. * I just don't have the time right now. */ stringmessage="An error has occurred"; if(message.Contains("error")) { thrownewException(message); } } }