<?xml version="1.0" encoding="utf-8" ?>
<rss version="2.0">
<channel>
	<title>Head First C#</title>
	<description><![CDATA[O'Reilly's Head First C# book forum]]></description>
	<link>http://forums.oreilly.com/index.php</link>
	<pubDate>Sun, 22 Nov 2009 19:29:16 -0500</pubDate>
	<ttl>120</ttl>
	<image>
		<title>Head First C#</title>
		<url>http://oreilly.com/catalog/covers/9780596514822_bkt.gif</url>
		<link>http://forums.oreilly.com/index.php</link>
	</image>
	<item>
		<title>How To Show Enums With Duplicate Values</title>
		<link>http://forums.oreilly.com/index.php?showtopic=5617</link>
		<description><![CDATA[I want to try and make a simulated game of blackjack. In the Go Fish game we use an enum in the Card class:<br /><br />public enum Values{<br />Ace = 1,<br />Two = 2,<br />..............<br />Ten = 10,<br />Jack = 11,<br />Queen = 12,<br />King = 13,<br /><br /><br />Is there a way to make a deck with Ten - King all = to 10?<br />Also, what would be the best way to make Ace = to either 1 or 11? <br />Should I not use an enum at all?]]></description>
		<pubDate>Sat, 21 Nov 2009 19:30:39 -0500</pubDate>
		<guid>http://forums.oreilly.com/index.php?showtopic=5617</guid>
	</item>
	<item>
		<title>Lumberjacks Problem</title>
		<link>http://forums.oreilly.com/index.php?showtopic=5593</link>
		<description><![CDATA[I'm working on the "Breakfast for Lumberjacks" exercise on pages 359/360. In the form class there are these lines of code for adding flapjacks:<br /><br />private void addFlapjacks_Click(object sender, EventArgs e)<br />        {<br />            Flapjack food;<br />            if (crispy.Checked == true)<br />                food = Flapjack.crispy;<br />            else if (soggy.Checked == true)<br />                food = Flapjack.soggy;<br />            else if (browned.Checked == true)<br />                food = Flapjack.browned;<br />            else<br />                food = Flapjack.banana;<br /><br />            Lumberjack currentLumberjack = breakfastLine.Peek();<br />            currentLumberjack.TakeFlapjacks(food,<br />                             (int)howMany.Value);<br />            RedrawList();<br />        }<br /><br />The problem is that Flapjack does not exist in the form class only the Lumberjack class. Flapjack is an enum in the Lumberjack class. Am I missing something or does this code in the book not make sense?]]></description>
		<pubDate>Wed, 18 Nov 2009 12:48:26 -0500</pubDate>
		<guid>http://forums.oreilly.com/index.php?showtopic=5593</guid>
	</item>
	<item>
		<title>Lab 1</title>
		<link>http://forums.oreilly.com/index.php?showtopic=5586</link>
		<description>I am stuck, cannot get past greyhound class.</description>
		<pubDate>Tue, 17 Nov 2009 17:33:12 -0500</pubDate>
		<guid>http://forums.oreilly.com/index.php?showtopic=5586</guid>
	</item>
	<item>
		<title><![CDATA[(chapter 1, Page 5) Shouldn't The Database Be In A Central Location?]]></title>
		<link>http://forums.oreilly.com/index.php?showtopic=5583</link>
		<description><![CDATA[First of all, let me congratulate you on this magnificent book<br /><br />I’ve only done reading chapter 1, and I like everything about the book; the style, the humor … everything!<br /><br />But there is something I don’t get in chapter one,<br /><br />In page 5 under the “user needs” what I understand is that we need to build an address book that the CEO will input his contacts in, and the sales team would be able to access this information.<br /><br />That means that the database needs to be in a central location with all the concerned people pointing to the same database (right?)<br />I mean, if it’s local on his machine (either the desktop or the laptop) he would need to update both to reflect the same thing and how will the sales team access this information?<br /><br />Unless you meant that I(the guy who developed the application) will be responsible for entering all his contacts and updating them as necessary, therefore, building the application whenever there is an update and distributing the new application (with the updated database) to all the concerned people.  <img src="http://forums.oreilly.com/style_emoticons/default/blink.gif" style="vertical-align:middle" emoid=":blink:" border="0" alt="blink.gif" /> <br /><br />And do I really have to publish such an application? Can’t it be distributed as a portable application (double click the .exe file)<br /><br />And why does the installer installs the application to the appdata under the user’s profile folder? That’s kinda weird?!<br /><br />Sorry for the long post  <img src="http://forums.oreilly.com/style_emoticons/default/biggrin.gif" style="vertical-align:middle" emoid=":D" border="0" alt="biggrin.gif" /> <br />]]></description>
		<pubDate>Tue, 17 Nov 2009 07:20:38 -0500</pubDate>
		<guid>http://forums.oreilly.com/index.php?showtopic=5583</guid>
	</item>
	<item>
		<title>More Problems With Lab 1</title>
		<link>http://forums.oreilly.com/index.php?showtopic=5580</link>
		<description><![CDATA[Run method:<br /><br /><div class='codetop'>CODE</div><div class='codemain' style='height:200px;white-space:pre;overflow:auto'>public bool Run()<br />        {<br />            <br />            int distance = Randomizer.Next(75) + 1;<br />            Point p = MyPictureBox.Location;<br />            p.X = p.X + distance;<br />            MyPictureBox.Location = p;<br /><br />            if (p.X &gt;= 555)<br />            {<br />                return true;<br />            }<br />            else<br />            {<br />                return false;<br />            }<br />        }</div><br /><br />method for clicking Race button:<br /><br /><div class='codetop'>CODE</div><div class='codemain' style='height:200px;white-space:pre;overflow:auto'>private void raceButton_Click(object sender, EventArgs e)<br />        {<br />            bool keepGoing = true;<br /><br />            while (keepGoing)<br />            {<br />                for (int i = 0; i &lt; Dogs.Length; i ++)<br />                {<br />                    bool checkWinner = Dogs[i].Run();<br />                    if (checkWinner == true)<br />                    {                        <br />                        keepGoing = false;<br />                        Winner = Dogs[i];<br />                        i = Dogs.Length + 1;<br />                    }<br />                    System.Threading.Thread.Sleep(50);<br />                }<br />            }<br /><br />            if (Winner == Dogs[0])<br />            {<br />                MessageBox.Show("Dog #1 wins the race!");<br />            }<br />            if (Winner == Dogs[1])<br />            {<br />                MessageBox.Show("Dog #2 wins the race!");<br />            }<br />            if (Winner == Dogs[2])<br />            {<br />                MessageBox.Show("Dog #3 wins the race!");<br />            }<br />            if (Winner == Dogs[3])<br />            {<br />                MessageBox.Show("Dog #4 wins the race!");<br />            }<br />        }</div><br /><br />With this code, dog #1 wins everytime. I added "i = Dogs.Length + 1" to the for loop to end the loop if there is a winner.]]></description>
		<pubDate>Mon, 16 Nov 2009 16:19:19 -0500</pubDate>
		<guid>http://forums.oreilly.com/index.php?showtopic=5580</guid>
	</item>
	<item>
		<title>Problem With Referencing Guy Object In Lab #1</title>
		<link>http://forums.oreilly.com/index.php?showtopic=5579</link>
		<description><![CDATA[I am working on lab 1 and doing ok with it so far, but I'm having trouble changing the "Name" label in the lower left hand corner of the GUI next to the "bets" button to reflect the name of the person whose radio button is currently selected. <br /><br />Here's the code where I create the Guy objects:<br /><br /><div class='codetop'>CODE</div><div class='codemain' style='height:200px;white-space:pre;overflow:auto'>public partial class Form1 : Form<br />    {<br />        Guy[] Guys;<br /><br />        Greyhound[] Dogs;  <br /><br />        public Form1()<br />        {<br />            InitializeComponent();<br /><br />            joeRadioButton.Checked = true;<br /><br />            Guys = new Guy[3];<br />            <br />            Guys[0] = new Guy() { Name = "Joe", Cash = 50, MyLabel = joeLabel, MyRadioButton = joeRadioButton };<br />            Guys[1] = new Guy() { Name = "Bob", Cash = 75, MyLabel = bobLabel, MyRadioButton = bobRadioButton };<br />            Guys[2] = new Guy() { Name = "Al", Cash = 45, MyLabel = alLabel, MyRadioButton = alRadioButton };<br /><br />            Dogs = new Greyhound[4];<br /><br />            Dogs[0] = new Greyhound() { MyPictureBox = dogPictureBox1 }; <br />            Dogs[1] = new Greyhound() { MyPictureBox = dogPictureBox2 };<br />            Dogs[2] = new Greyhound() { MyPictureBox = dogPictureBox3 };<br />            Dogs[3] = new Greyhound() { MyPictureBox = dogPictureBox4 };</div><br /><br />And here's the code for changing the Name label when a new Radio button is selected:<br /><br /><div class='codetop'>CODE</div><div class='codemain' style='height:200px;white-space:pre;overflow:auto'>public void joeRadioButton_CheckedChanged(object sender, EventArgs e)<br />        {<br />            nameLabel.Text = Guys[0].Name;<br />        }<br /><br />        private void bobRadioButton_CheckedChanged(object sender, EventArgs e)<br />        {<br />            nameLabel.Text = Guys[1].Name;<br />        }<br /><br />        private void alRadioButton_CheckedChanged(object sender, EventArgs e)<br />        {<br />            nameLabel.Text = Guys[2].Name;<br />        }</div><br /><br />When I try to debug, I get an error message that says "Object reference not set to instance of an object" with "nameLabel.Text = Guys[0].Name" highlighted. But isn't Guys[0] an instance of the Guy object?]]></description>
		<pubDate>Mon, 16 Nov 2009 12:23:04 -0500</pubDate>
		<guid>http://forums.oreilly.com/index.php?showtopic=5579</guid>
	</item>
	<item>
		<title>How To Use Tablealayoutpanel</title>
		<link>http://forums.oreilly.com/index.php?showtopic=5573</link>
		<description><![CDATA[The Lab #2 say to lay out the move and attack buttons with a tablelayoutpanel. <br /><br />How?!!<br /><br />As far as I can tell you can only layout in columns and rows. The layout for for attack and move buttons are more of a diamond.]]></description>
		<pubDate>Sun, 15 Nov 2009 17:54:17 -0500</pubDate>
		<guid>http://forums.oreilly.com/index.php?showtopic=5573</guid>
	</item>
	<item>
		<title>Lab#1 (day At The Races) – How Can I Get Rid Of Dog‘s “spoors”?</title>
		<link>http://forums.oreilly.com/index.php?showtopic=5572</link>
		<description><![CDATA[Hello Everyone<br /><br />Finally, my version of the greyhound race program seems to work and I have got rid of all bugs except a cosmetic issue: all dogs will leave behind them some sort of footprint or spoor (please refer to the attached screenshot with red arrows).<br />I guess these spoors result somehow from the dog picture having been positioned a little more leftwards some instances before. But I do not fully understand, as the pictures MOVE from the left to the right and pictures are not COPIED as can be seen from the code snippet below:<br /><br /><div class='codetop'>CODE</div><div class='codemain' style='height:200px;white-space:pre;overflow:auto'>public bool Laufen (){<br />            int distanz = Zufallszahl.Next(1, 5);<br />            Point p = Bild.Location;<br />            p.X += distanz;<br />            Bild.Location = p;<br />            Ort = p.X;<br />            if (Ort &gt;= RennbahnLänge)<br />            {<br />            return true;<br />                }<br />            else<br />                {<br />            return false;<br />            }<br /></div><br /><br />As soon as the fist dog reaches the end of the race track, a messagebox pops up stating which greyhound has won (dogs have not taken their starting position again). At this moment all the spoors will disspear.<br />How can this phenomenon be explained and is there a way to change the code in order to get rid of this effect?<br /><br />Thank you for any advice <br />Michi<br />]]></description>
		<pubDate>Sun, 15 Nov 2009 13:50:27 -0500</pubDate>
		<guid>http://forums.oreilly.com/index.php?showtopic=5572</guid>
	</item>
	<item>
		<title>Pool Puzzle - Chapter 7</title>
		<link>http://forums.oreilly.com/index.php?showtopic=5557</link>
		<description><![CDATA[The answer for this puzzle has class Of76 inheriting from Clowns. That works but I said it inherits from Picasso. Will this not also work? Am I wrong? <br /><br />]]></description>
		<pubDate>Thu, 12 Nov 2009 16:53:37 -0500</pubDate>
		<guid>http://forums.oreilly.com/index.php?showtopic=5557</guid>
	</item>
	<item>
		<title>Chapter 2 Change It Back So It Opens Contacts Again.</title>
		<link>http://forums.oreilly.com/index.php?showtopic=5546</link>
		<description><![CDATA[Hi, I just started this book, and I love the style of it! I have been working through all the examples and came to the part in Chapter 2 where you change the entry point on the program. There is a question that says to figure out how to change it so that it opens up Contacts again. The hint says you need to change 2 lines in 2 files to accomplish this, but I was able to accomplish the same thing by adding just one line. In the code for AnotherClass.cs, after the line that opens up the message box, just add the following line:<br /><br />Contacts.Program.NotMain();<br /><br />That calls the original Main() and everything else just follows.<br /><br /><br />"Don't sweat the small stuff!" <br />"It's all small stuff!"]]></description>
		<pubDate>Mon, 09 Nov 2009 20:36:26 -0500</pubDate>
		<guid>http://forums.oreilly.com/index.php?showtopic=5546</guid>
	</item>
	<item>
		<title>The First Dog On The Racetrack Keeps Running Off The Screen</title>
		<link>http://forums.oreilly.com/index.php?showtopic=5544</link>
		<description><![CDATA[I have tried to follow the design notes in the book, and gotten a lot of help from the forum with getting started on Lab1. The way I have broken down the problem is to first get all the dogs to run across the track, without any betting. I believe I have my objects correctly initialized and the basic setup ok. However, my logic is amiss somewhere. All the dogs start the race at the same time, but the first dog always runs off the track, while the other dogs stop at the end of the race. My code snippets are below. Thanks for your help.<br /><br />Greyhound.cs:<br /><div class='codetop'>CODE</div><div class='codemain' style='height:200px;white-space:pre;overflow:auto'><br />using System;<br />using System.Collections.Generic;<br />using System.Linq;<br />using System.Text;<br />using System.Windows.Forms;<br />using System.Drawing;<br /><br />namespace DogRace<br />{<br />    public class Greyhound<br />    {<br />        public int StartingPosition;            // Where my picturebox starts<br />        public int RacetrackLength;             // How long the racetrack is<br />        public PictureBox MyPictureBox = null;  // My Picturebox object<br />        public int Location = 0;                // My location on the racetrack<br />        public Random Randomizer;               // An instance of Random<br /><br />        public bool Run()<br />        { <br />            // Move forward either 1, 2, 3, or 4 spaces at random<br />            // Update the position of my Picturebox on the form<br />            // Return true if I won the race<br />            int distance = Randomizer.Next(4);<br />            Point p = MyPictureBox.Location;<br />            p.X += distance;<br />            MyPictureBox.Location = p;<br /><br />            //slow things down a bit...<br />            Application.DoEvents();<br />            System.Threading.Thread.Sleep(3);<br /><br />            <br />            if (p.X &gt;= RacetrackLength)<br />            {<br />                return true;<br />            }<br />            else<br />            {<br />                return false;<br />            }<br />        }<br /><br />        public void TakeStartingPosition()<br />        { <br />            // reset my location to the start line <br />            // the start line is the width of the racetrack picBox - the width of the dog picBox<br />            MyPictureBox.Left = StartingPosition;<br />        }<br />    }<br />}</div><br /><br />And Form.cs:<br /><div class='codetop'>CODE</div><div class='codemain' style='height:200px;white-space:pre;overflow:auto'><br />using System;<br />using System.Collections.Generic;<br />using System.ComponentModel;<br />using System.Data;<br />using System.Drawing;<br />using System.Linq;<br />using System.Text;<br />using System.Windows.Forms;<br /><br />namespace DogRace<br />{<br />    public partial class Form1 : Form<br />    {<br />        Guy[] guys = new Guy[3];<br />        Greyhound[] dogs = new Greyhound[4];<br />        Random globalRandomVariable = new Random();<br /><br />        public Form1()<br />        {<br />            InitializeComponent();<br /><br />            // Initialize the guys on the form<br />            guys[0] = new Guy() { Name = "Joe", Cash = 50, MyBet = null, MyLabel = joesLabel, MyRadioButton = joesRadio };<br />            guys[1] = new Guy() { Name = "Bob", Cash = 75, MyBet = null, MyLabel = bobsLabel, MyRadioButton = bobsRadio };<br />            guys[2] = new Guy() { Name = "Al", Cash = 45, MyBet = null, MyLabel = AlsLabel, MyRadioButton = AlsRadio };<br /><br />            <br />            // Initialize the dogs on the form<br />            dogs[0] = new Greyhound() { RacetrackLength = pbRaceTrack.Width - pbDog1.Width, Location = pbDog1.Location.X, MyPictureBox = pbDog1, Randomizer = globalRandomVariable, StartingPosition = pbRaceTrack.Width - pbDog1.Width };<br />            dogs[1] = new Greyhound() { RacetrackLength = pbRaceTrack.Width - pbDog2.Width, Location = pbDog2.Location.X, MyPictureBox = pbDog2, Randomizer = globalRandomVariable, StartingPosition = pbRaceTrack.Width - pbDog2.Width };<br />            dogs[2] = new Greyhound() { RacetrackLength = pbRaceTrack.Width - pbDog3.Width, Location = pbDog3.Location.X, MyPictureBox = pbDog3, Randomizer = globalRandomVariable, StartingPosition = pbRaceTrack.Width - pbDog3.Width };<br />            dogs[3] = new Greyhound() { RacetrackLength = pbRaceTrack.Width - pbDog4.Width, Location = pbDog4.Location.X, MyPictureBox = pbDog4, Randomizer = globalRandomVariable, StartingPosition = pbRaceTrack.Width - pbDog4.Width };<br /><br />            // Run a quick loop to update the labels on the form<br />            for (int i = 0; i &lt; guys.Length; i++)<br />            {<br />                guys[i].UpdateLabels();<br />            }        <br />        }<br /><br />        // This is where all the dogs run<br />        private void button2_Click(object sender, EventArgs e)<br />        {<br />            while (true)<br />            {<br />                for (int i = 0; i &lt; dogs.Length && !(dogs[i].Run()); i++)<br />                {   <br />                    dogs[i].Run();<br />                }<br />            }<br />        }<br /><br />        private void joesRadio_CheckedChanged(object sender, EventArgs e)<br />        {<br />            bettorLabel.Text = "Joe";<br />        }<br /><br />        private void bobsRadio_CheckedChanged(object sender, EventArgs e)<br />        {<br />            bettorLabel.Text = "Bob";<br />        }<br /><br />        private void AlsRadio_CheckedChanged(object sender, EventArgs e)<br />        {<br />            bettorLabel.Text = "Al";<br />        }<br />    }<br /><br />}<br /></div>]]></description>
		<pubDate>Mon, 09 Nov 2009 16:22:23 -0500</pubDate>
		<guid>http://forums.oreilly.com/index.php?showtopic=5544</guid>
	</item>
	<item>
		<title>Chapter 1 Contacts : User Setup Install Directory Choice</title>
		<link>http://forums.oreilly.com/index.php?showtopic=5490</link>
		<description><![CDATA[Does anyone know how to allow the Setup program for Contacts to give the user a choice as to where to install the Contacts program?<br /><br />I would like to be able to have the user install the Contacts program to any location on their hard drive, not just the default location.<br /><br />I would like that choice to appear during setup.<br /><br />The C# Express 2008 help system does not give a clear answer that I could find.<br /><br />Any help is appreciated.   <img src="http://forums.oreilly.com/style_emoticons/default/blink.gif" style="vertical-align:middle" emoid=":blink:" border="0" alt="blink.gif" />]]></description>
		<pubDate>Wed, 28 Oct 2009 15:08:03 -0400</pubDate>
		<guid>http://forums.oreilly.com/index.php?showtopic=5490</guid>
	</item>
	<item>
		<title>Lab #1 : Labeling Array Of Dogs</title>
		<link>http://forums.oreilly.com/index.php?showtopic=5486</link>
		<description><![CDATA[TO make a long story short, I'm learning C# for the first time with the Head First book, altough I've used Visual Basic for a while(which tends to screw me up a bit). <br /><br />I created the form via designer as shown and created the empty classes. I wanted to get the Dog racing part done first so I added the following code to form1.cs:<br /><br /><!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->namespace DogRaceLab<br />{<br />&nbsp;&nbsp;&nbsp;&nbsp;public partial class Form1 &#58; Form<br />&nbsp;&nbsp;&nbsp;&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;public bool winner;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;public Form1&#40;&#41;<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;InitializeComponent&#40;&#41;;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;GreyHound&#91;&#93; Dog = new GreyHound&#91;4&#93;;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for &#40;int x = 0; x &#60; 4; x++&#41;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Dog&#91;x&#93; = new GreyHound&#40;&#41; { StartingPos = &#40;&#40;&#40;x + 1&#41; * 50&#41; - 34&#41;, };<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if &#40;x == 0&#41; { Dog&#91;x&#93;.MyImage = pic0; }<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if &#40;x == 1&#41; { Dog&#91;x&#93;.MyImage = pic1; }<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if &#40;x == 2&#41; { Dog&#91;x&#93;.MyImage = pic2; }<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if &#40;x == 3&#41; { Dog&#91;x&#93;.MyImage = pic3; }<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Dog&#91;x&#93;.TakeStartPos&#40;&#41;;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;private void button1_Click&#40;object sender, EventArgs e&#41;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;while &#40;winner == false&#41;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Dog&#91;1&#93;.run&#40;&#41;; //originally was an for loop, but ran into same issue and reduced for simplicity<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />}<!--c2--></div><!--ec2--><br /><br />Greyhound.cs:<br /><!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->class GreyHound<br />&nbsp;&nbsp;&nbsp;&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//Declare var<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;public int StartingPos;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;public int LengthofTrack;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;public int CurrentPos;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;public PictureBox MyImage = null;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;public Random Randomizer;<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;public bool Run&#40;&#41;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//moves the dog either 1-4 spaces at random<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//updates the picturebox<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//returns true if crosses the finish line&#40;600&#41;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if &#40;this.MyImage.Location.X &#60; 600&#41;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;int roll = this.Randomizer.Next&#40;4&#41;;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;int Y; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;int X = this.MyImage.Location.X;<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Y = X + roll;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;X = Y;<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return false;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return true;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp;&nbsp;public void TakeStartPos&#40;&#41;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//Reset dog location<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;int Y = StartingPos;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;int X = 5;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;this.MyImage.Location = new Point&#40;X, Y&#41;;<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />&nbsp;&nbsp;&nbsp;&nbsp;}<!--c2--></div><!--ec2--><br /><br />The error I get is:<br /><br />Error	1	The name 'Dog' does not exist in the current context	41	17	DogRaceLab<br /><br />It seems I can't use the array references outside of the intial setup. I want to call .Run() for each dog, but am uncertain how to get labels pointing to them in Button1_click. Any ideas?<br /><br />On a side note, I had to jury-rig the picturebox labels as I couldn't get them to run inside the for loop either, so any help there would also be appreciated. <br /><br />I know it's got to be something I've missed, but I can't figure out what it is.<br /><br /><br />]]></description>
		<pubDate>Tue, 27 Oct 2009 23:56:03 -0400</pubDate>
		<guid>http://forums.oreilly.com/index.php?showtopic=5486</guid>
	</item>
	<item>
		<title><![CDATA[Override And Virtual -- Bonus "sharpen"! (i'd Love Some Feedback...)]]></title>
		<link>http://forums.oreilly.com/index.php?showtopic=5485</link>
		<description><![CDATA[For anyone who didn't see it on <a href="http://forums.oreilly.com/content/Head-First-C-/3806/Overriding-Methods-In-Base-Class-Chapter-6/" target="_blank">the thread about how to use the override and virtual keywords</a>, I posted an entry on the O'Reilly C# blog called <a href="http://broadcast.oreilly.com/2009/10/understanding-c-using-virtual.html" target="_blank"><b>Understanding C#: Using virtual and override</b></a>. My goal is to give you a good example of exactly why the <i>override</i> and <i>virtual</i> keywords are useful. I included a "Sharpen Your Pencil" exercise, the same kind that you see throughout the book.<br /><br />I'm just getting started on the 2nd edition of the book (which we'll be releasing to coincide with Microsoft's new release of Visual Studio 2010 and C# 4.0), and I'd love some feedback. I'm thinking about using this in the new version of the book, and it'd be great to know if you guys think it would be helpful.<br /><br />If I get a lot of feedback, I'll see if I can "test run" more of the new material for the book here and in blog posts. (That way anyone interested won't miss out on it!)<br /><br />Thanks!]]></description>
		<pubDate>Tue, 27 Oct 2009 18:30:20 -0400</pubDate>
		<guid>http://forums.oreilly.com/index.php?showtopic=5485</guid>
	</item>
	<item>
		<title><![CDATA[No "save The Connection" Checkbox From Chapter 1]]></title>
		<link>http://forums.oreilly.com/index.php?showtopic=5483</link>
		<description><![CDATA[I'm just starting out with this book, on the first project. On page 31, where you configure the datasource, there is an instruction that says:<br /><br />Make sure to Save the connection checkbox is checked in the "Save the Connection" screen that follows and click next.<br /><br />The problem is, there was no checkbox for that on the screen. I guess it's not a huge deal, but I want to make sure I'm not doing something wrong, and that the connection will be saved as I move forward in the program.]]></description>
		<pubDate>Tue, 27 Oct 2009 17:14:47 -0400</pubDate>
		<guid>http://forums.oreilly.com/index.php?showtopic=5483</guid>
	</item>
</channel>
</rss>