Visio Guy

Visio Discussions => Programming & Code => Topic started by: Paul Herber on July 11, 2020, 05:18:41 PM

Title: Interesting C# syntax problem
Post by: Paul Herber on July 11, 2020, 05:18:41 PM
While investigating a bug in some code for a Visio C# addon I eventually found the problem:
I had:
  for (int i=0; i <- p1.RowCount[(short)section]-1; i++)
instead of:
  for (int i=0; i <= p1.RowCount[(short)section]-1; i++)

I would have thought that the space between the '-' and p1 would give an error. Obviously not.
Title: Re: Interesting C# syntax problem
Post by: Paul Herber on July 13, 2020, 08:00:25 AM
Some interesting responses:
https://stackoverflow.com/questions/62865675/c-sharp-for-loop-syntax-query-why-does-this-compile?noredirect=1#62865862 (https://stackoverflow.com/questions/62865675/c-sharp-for-loop-syntax-query-why-does-this-compile?noredirect=1#62865862)