Wrox Programmer Forums
|
BOOK: Beginning Microsoft Visual C# 2008 ISBN: 978-0-470-19135-4
This is the forum to discuss the Wrox book Beginning Microsoft Visual C# 2008 by Karli Watson, Christian Nagel, Jacob Hammer Pedersen, Jon D. Reid, Morgan Skinner, Eric White; ISBN: 9780470191354
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning Microsoft Visual C# 2008 ISBN: 978-0-470-19135-4 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 April 6th, 2010, 06:55 PM
Registered User
 
Join Date: Mar 2010
Posts: 3
Thanks: 1
Thanked 0 Times in 0 Posts
Default A better example of Chapter 5 Question 6

I have found that using the code from the Downloaded answers can destroy any word that has the no in it such as another would be changed to ayesther. I don't think this would be acceptable but I have a simple cure:

Code on Answer Sheet:

static void Main(string[] args)
{
Console.WriteLine("Enter a string:");
string myString = Console.ReadLine();
myString = myString.Replace("no", "yes");
Console.WriteLine("Replaced \"no\" with \"yes\": {0}", myString);

Preferred code:

static void Main(string[] args)
{
Console.WriteLine("Enter a string with lots of no's");
string myString = Console.ReadLine();
myString = myString.ToLower(); // catch all variations of no
myString = myString.Replace(" no ", " yes "); // note the space before and after no and yes.
Console.WriteLine("I have switched \"no\" with \"yes\" and here is the result\n\n {0}", myString);
Console.ReadKey();
 
Old April 6th, 2010, 08:16 PM
Friend of Wrox
 
Join Date: Dec 2008
Posts: 238
Thanks: 2
Thanked 20 Times in 19 Posts
Default

Good stuff!





Similar Threads
Thread Thread Starter Forum Replies Last Post
Chapter 5 Question jltscaa BOOK: Beginning Microsoft Visual Basic 2008 ISBN: 978-0-470-19134-7 6 May 18th, 2010 08:39 PM
Chapter 5 Question 5 Will BOOK: Beginning Microsoft Visual C# 2008 ISBN: 978-0-470-19135-4 1 October 24th, 2009 09:18 AM
Question on Chapter 5 arholly BOOK: Expert Access 2007 Programming ISBN 978-0-470-17402-9 1 September 2nd, 2008 04:07 PM
Chapter 4 question davidle1234 BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 2 January 18th, 2007 12:18 AM





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