//C# Herhalingen met For ... Next Basisstructuren van Algoritmes public class ForNextExample1 { void Main() { int value; Console.WriteLine(value); Console.ReadLine(); } } public class ForNextWithStartValueOtherThan1Example { void Main() { int value; Console.WriteLine(value); Console.ReadLine(); } } public class ForNextWithStepValueExample { void Main() { int value; Console.WriteLine(value); Console.ReadLine(); } } public class ForNextWithNegativeStepValueExample { void Main() { int value; Console.WriteLine(value); Console.ReadLine(); } } public class ForNextExample2 { void Main() { int countValue; int startValue = 1; int endValue = 10; int stepValue = 2; Console.WriteLine("values during iteration :"); Console.WriteLine(("count value : " + countValue)); countValue = (countValue + 1); startValue = (startValue + 1); endValue = (endValue + 1); stepValue = (stepValue + 1); Console.WriteLine("values after iteration :"); Console.WriteLine(("count value : " + countValue)); Console.WriteLine(("start value : " + startValue)); Console.WriteLine(("end value : " + endValue)); Console.WriteLine(("step value : " + stepValue)); Console.ReadLine(); } } public class ForNextExercise1 { void Main() { Console.WriteLine("Value ?"); int value = Console.ReadLine(); int factorial = value; int factor = (value - 1); factorial = (factorial * factor); Console.WriteLine(((value + "! = ") + factorial)); Console.ReadLine(); } } public class ForNextExercise2 { void Main() { int hours; int minutes; int seconds; string timeLabel; timeLabel = ""; if ((hours < 10)) { timeLabel = "0"; } timeLabel = ((timeLabel + hours) + "h"); if ((minutes < 10)) { timeLabel = (timeLabel + "0"); } timeLabel = ((timeLabel + minutes) + "m"); if ((seconds < 10)) { timeLabel = (timeLabel + "0"); } timeLabel = ((timeLabel + seconds) + "s"); Console.WriteLine(timeLabel); Console.ReadLine(); } } //Bezoek www.vbvoorbeelden.be voor meer C# voorbeelden. //Copyright - De Wolf / vbvoorbeelden - 2003-2011 - Alle rechten voorbehouden.