i bought a book on C# by Head First .. and there is SO MUCH bugs, i have 15 errors. I have checked the errata as well for this but this is not listed.
i created a class called Talker as the book shown and have went through te code with a bone comb, here it is:
namespace WindowsFormsApplication1
{
class Talker
{
public static int BlaBlaBla(string thingToSay, int numberOfTimes);
string finalString = "";
for (int count =1; count <= numberoftimes; count++)
{
finalstring = finalstring + thingtosay + "\n";
}
MessageBox.Show(finalstring);
return finalstring.Length;
}
}
i have lots of them saying "invalid token in class"
thanks
Loading

FroglegRank #1,020 · 1.9K reputationPosted Dec 15, 2010, 9:29 AM EST
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
int i = Talker.BlaBlaBla("whatever", 5);
}
}
class Talker
{
public static int BlaBlaBla(string thingToSay, int numberOfTimes)
{
string finalString = "";
for (int count =1; count <= numberOfTimes; count++)
{
finalString = finalString + thingToSay + "\n";
}
MessageBox.Show(finalString);
return finalString.Length;
}
This is how i got it to work.
John Burns116 reputationPosted Dec 15, 2010, 8:27 AM EST
John Burns116 reputationPosted Dec 15, 2010, 9:09 AM EST
if i cant sort this then there is no point studying c# with a book thats as useful as a sponge umbrella!
John Burns116 reputationPosted Dec 15, 2010, 10:10 AM EST
this casued 15 errors and missery ... thanks lol :)
Suthish NairRank #92 · 22.8K reputationPosted Dec 16, 2010, 12:39 AM EST
Nice to hear, you got through the error. This is how we learn programming, from mistakes only.
Keep posting the queries.
Also, remember to mark the post as accepted answer, this will help others in future.
John Burns116 reputationPosted Dec 16, 2010, 12:44 AM EST
feels frustrating when the problem happens, but feels even better when you solvwe it :)
John Burns116 reputationPosted Dec 16, 2010, 12:44 AM EST
feels frustrating when the problem happens, but feels even better when you solvwe it :)