Wrox Programmer Forums
|
BOOK: Beginning Visual C#
This is the forum to discuss the Wrox book Beginning Visual C#, Revised Edition of Beginning C# for .NET v1.0 by Karli Watson, David Espinosa, Zach Greenvoss, Jacob Hammer Pedersen, Christian Nagel, Jon D. Reid, Matthew Reynolds, Morgan Skinner, Eric White; ISBN: 9780764543821
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning Visual C# section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 19th, 2006, 06:22 AM
Authorized User
 
Join Date: Nov 2005
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default variation in programming

Hello,

Im just working my way through the book and just doing the excersizes in chapter 5. This is what i wrote for Q5 before I looked at the answer given

Console.WriteLine("Please enter a string to be written backwards:");
string myString=Console.ReadLine();
char[] myChar = myString.ToCharArray();
for (int i=1;i<= myString.Length;i++)
{
    Console.Write(myChar[myString.Length-i]);
}
Console.Write("\n");

The answer given,

         Console.WriteLine("Enter a string:");
         string myString = Console.ReadLine();
         string reversedString = "";
         for (int index = myString.Length - 1; index >= 0; index--)
         {
            reversedString += myString[index];
         }
         Console.WriteLine("Reversed: {0}", reversedString);

My question is, Is my answer fine as it does the same thing, and what are the advantages/disadvantages of writing the way its given in the textbook answer. Overheads?

Any reply ould be greatly appreciated





Similar Threads
Thread Thread Starter Forum Replies Last Post
device DLL programming in client side programming hendyhanusin ASP.NET 1.0 and 1.1 Professional 2 February 19th, 2009 12:01 PM
device DLL programming in client side programming hendyhanusin ASP.NET 1.0 and 1.1 Basics 0 March 21st, 2007 08:05 AM
device DLL programming in client side programming hendyhanusin ASP.NET 2.0 Professional 1 March 21st, 2007 08:04 AM
Qt programming, bugs in first programming sateeshgalla BOOK Beginning Linux Programming, 3rd Edition 0 October 14th, 2005 08:19 AM
OLEDB connection string variation Edward Stephen Classic ASP Databases 4 November 2nd, 2004 10:26 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.