Stupid Questions: Beginner needing help understanding .ToString and break

I'm taking Bob Tabor's "C# For Absolute Beginners" course, and I just can't for the life of me understand these two things. In lesson 9 about For iterations I've spent about 2 hours so far trying to figure out what should be a 13 minute lesson.

.ToString in the example does nothing, or rather had no different effect than just using the variable by itself like: Console.WriteLine(i);

as opposed to:


The same issue for break, it returns no different result if you break it out or not. I just don't get what these are supposed to do exactly. I've looked up the reference info for them, but it's just not making sense to me. Can someone please explain to me like I'm 5 years old (might as well be right now) what the hell is going on with them precisely?

Here is the code

.ToString example:

 for (int i = 1; i < 10; i++) { Console.WriteLine(i.ToString()); } Console.ReadLine(); 

break; example:

for (int i = 1; i < 10; i++) { if (i == 7) { Console.WriteLine("Found seven!"); break; } 

Thanks in advance; this is driving me nuts.

by stuckoutofluck via /r/csharp

Leave a Reply