Author Topic: News to me  (Read 549 times)

0 Members and 1 Guest are viewing this topic.

kdub_nz

  • Mesozoic keyThumper
  • SuperMod
  • Water Moccasin
  • Posts: 2133
  • class keyThumper<T>:ILazy<T>
News to me
« on: December 31, 2023, 03:16:45 AM »
This is something I wasn't aware of  . . . after 20 odd years
The for loop control can have additional statements which execute along with the
initialise statement and increment/step statement
but apparently not with the test statement.

something new every day is a good thing !

Code - C#: [Select]
  1. // See https://aka.ms/new-console-template for more information
  2.  
  3. using System;
  4. namespace Basics;
  5. class Program
  6. {
  7.    static void Main()
  8.    {
  9.       Console.WriteLine("Hello, CH02 : Vocabulary");
  10.  
  11.       Console.WriteLine($"Namespace: {typeof(Program).Namespace}\n");
  12.  
  13.       int i;
  14.       int j = 3;
  15.  
  16.       for (i = 0, Console.WriteLine($"Start: i={i}, j={j}");
  17.             i < j;
  18.             i++, j--, Console.WriteLine($"Step: i={i}, j={j}"))
  19.       {
  20.          //...
  21.       }
  22.       /*
  23.       Hello, CH02: Vocabulary
  24.       Namespace: Basics
  25.  
  26.       Start: i = 0, j = 3
  27.       Step: i = 1, j = 2
  28.       Step: i = 2, j = 1
  29.       */
  30.    }
  31. }
  32.  
  33.  
Called Kerry in my other life
Retired; but they dragged me back in !

I live at UTC + 13.00

---
some people complain about loading the dishwasher.
Sometimes the question is more important than the answer.